feat(realtime): add websocket gateway and command ack/retry flow

This commit is contained in:
2026-01-09 13:15:00 +00:00
parent d51bac5a66
commit 250d072e8b
3 changed files with 512 additions and 1 deletions

View File

@@ -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}`);
});
};