feat(web): add Express + WebSocket server entry
This commit is contained in:
37
web/server/index.ts
Normal file
37
web/server/index.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import { createServer } from 'http';
|
||||
import { WebSocketServer } from 'ws';
|
||||
import { initDb } from './db';
|
||||
import { accountsRouter } from './routes/accounts';
|
||||
import { promptsRouter } from './routes/prompts';
|
||||
import { pipelineRouter } from './routes/pipeline';
|
||||
import { assetsRouter } from './routes/assets';
|
||||
import { configsRouter } from './routes/configs';
|
||||
|
||||
const app = express();
|
||||
const server = createServer(app);
|
||||
const wss = new WebSocketServer({ server, path: '/ws' });
|
||||
|
||||
app.use(cors());
|
||||
app.use(express.json({ limit: '50mb' }));
|
||||
|
||||
app.use('/api/accounts', accountsRouter);
|
||||
app.use('/api/prompts', promptsRouter);
|
||||
app.use('/api/pipeline', pipelineRouter);
|
||||
app.use('/api/assets', assetsRouter);
|
||||
app.use('/api/configs', configsRouter);
|
||||
|
||||
wss.on('connection', (ws) => {
|
||||
// Placeholder - will be replaced in Task 3.1
|
||||
console.log('WebSocket client connected');
|
||||
ws.on('message', (data) => {
|
||||
console.log('received:', data.toString());
|
||||
});
|
||||
});
|
||||
|
||||
const PORT = 3001;
|
||||
initDb();
|
||||
server.listen(PORT, () => {
|
||||
console.log(`Server running on http://localhost:${PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user