feat(realtime): add websocket gateway and command ack/retry flow
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import express from 'express';
|
||||
import { createServer } from 'http';
|
||||
import { toNodeHandler } from 'better-auth/node';
|
||||
import swaggerUi from 'swagger-ui-express';
|
||||
|
||||
@@ -8,6 +9,8 @@ import videosRoutes from './routes/videos';
|
||||
import adminRoutes from './routes/admin';
|
||||
import devicesRoutes from './routes/devices';
|
||||
import deviceLinksRoutes from './routes/device-links';
|
||||
import commandsRoutes from './routes/commands';
|
||||
import { setupRealtimeGateway } from './realtime/gateway';
|
||||
import { ensureMinioBucket } from './utils/minio';
|
||||
|
||||
const app = express();
|
||||
@@ -30,6 +33,7 @@ app.use('/videos', videosRoutes);
|
||||
app.use('/admin', adminRoutes);
|
||||
app.use('/devices', devicesRoutes);
|
||||
app.use('/device-links', deviceLinksRoutes);
|
||||
app.use('/commands', commandsRoutes);
|
||||
|
||||
app.use((err: unknown, _req: express.Request, res: express.Response, _next: express.NextFunction) => {
|
||||
console.error(err);
|
||||
@@ -37,6 +41,7 @@ app.use((err: unknown, _req: express.Request, res: express.Response, _next: expr
|
||||
});
|
||||
|
||||
const port = Number(process.env.PORT ?? 3000);
|
||||
const server = createServer(app);
|
||||
|
||||
const start = async () => {
|
||||
try {
|
||||
@@ -46,7 +51,9 @@ const start = async () => {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
app.listen(port, () => {
|
||||
setupRealtimeGateway(server);
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log(`Server is running on port ${port}`);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user