- Created manifest.yaml with Node.js runtime and routes - Set up package.json with React, TypeScript, Vite, and dependencies - Created TypeScript and Vite configuration files - Set up ESLint and Prettier - Created complete directory structure (frontend, backend, migrations) - Created initial database schema migration - Set up Express server with route handlers - Created frontend entry point files - Added version.txt with build 0.1.0.001
123 lines
3.5 KiB
JavaScript
123 lines
3.5 KiB
JavaScript
// BP_WB - BOSA Plugin Website Builder
|
|
// Main entry point for Node.js runtime
|
|
|
|
import { BOSA } from 'bosa-sdk-node';
|
|
import express from 'express';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
// Initialize BOSA SDK
|
|
const bosa = new BOSA({
|
|
kernelURL: process.env.BOSA_KERNEL_URL || 'http://localhost:3000',
|
|
pluginName: process.env.PLUGIN_NAME || 'bp_wb',
|
|
pluginToken: process.env.BOSA_KERNEL_TOKEN,
|
|
});
|
|
|
|
// Initialize Express app
|
|
const app = express();
|
|
const port = process.env.PLUGIN_PORT || 3001;
|
|
|
|
// Middleware
|
|
app.use(express.json());
|
|
app.use(express.static(path.join(__dirname, 'dist')));
|
|
|
|
// Health check endpoint
|
|
app.get('/health', (req, res) => {
|
|
res.json({ status: 'ok', plugin: 'bp_wb' });
|
|
});
|
|
|
|
// Route handlers (to be implemented in backend/api/)
|
|
app.get('/', serveEditor);
|
|
app.get('/editor', serveEditor);
|
|
app.get('/api/pages', listPages);
|
|
app.post('/api/pages', createPage);
|
|
app.get('/api/pages/:id', getPage);
|
|
app.put('/api/pages/:id', updatePage);
|
|
app.delete('/api/pages/:id', deletePage);
|
|
app.get('/preview/:id', previewPage);
|
|
|
|
// Placeholder route handlers (to be implemented in Phase 1)
|
|
async function serveEditor(req, res) {
|
|
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
|
|
}
|
|
|
|
async function listPages(req, res) {
|
|
try {
|
|
// TODO: Implement in WB-006
|
|
res.json({ pages: [] });
|
|
} catch (error) {
|
|
bosa.log.error(`ListPages failed | Error: ${error.message}`);
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
}
|
|
}
|
|
|
|
async function createPage(req, res) {
|
|
try {
|
|
// TODO: Implement in WB-006
|
|
res.status(501).json({ error: 'Not implemented yet' });
|
|
} catch (error) {
|
|
bosa.log.error(`CreatePage failed | Error: ${error.message}`);
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
}
|
|
}
|
|
|
|
async function getPage(req, res) {
|
|
try {
|
|
// TODO: Implement in WB-006
|
|
res.status(501).json({ error: 'Not implemented yet' });
|
|
} catch (error) {
|
|
bosa.log.error(`GetPage failed | Page ID: ${req.params.id} | Error: ${error.message}`);
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
}
|
|
}
|
|
|
|
async function updatePage(req, res) {
|
|
try {
|
|
// TODO: Implement in WB-006
|
|
res.status(501).json({ error: 'Not implemented yet' });
|
|
} catch (error) {
|
|
bosa.log.error(`UpdatePage failed | Page ID: ${req.params.id} | Error: ${error.message}`);
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
}
|
|
}
|
|
|
|
async function deletePage(req, res) {
|
|
try {
|
|
// TODO: Implement in WB-006
|
|
res.status(501).json({ error: 'Not implemented yet' });
|
|
} catch (error) {
|
|
bosa.log.error(`DeletePage failed | Page ID: ${req.params.id} | Error: ${error.message}`);
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
}
|
|
}
|
|
|
|
async function previewPage(req, res) {
|
|
try {
|
|
// TODO: Implement in WB-007
|
|
res.status(501).json({ error: 'Not implemented yet' });
|
|
} catch (error) {
|
|
bosa.log.error(`PreviewPage failed | Page ID: ${req.params.id} | Error: ${error.message}`);
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
}
|
|
}
|
|
|
|
// Initialize BOSA and start server
|
|
async function init() {
|
|
try {
|
|
await bosa.init();
|
|
bosa.log.info('BP_WB plugin initialized successfully');
|
|
|
|
app.listen(port, () => {
|
|
bosa.log.info(`BP_WB plugin server running on port ${port}`);
|
|
});
|
|
} catch (error) {
|
|
console.error('Failed to initialize BP_WB plugin:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
init();
|
|
|