-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.mjs
More file actions
40 lines (32 loc) · 1.2 KB
/
Copy pathserver.mjs
File metadata and controls
40 lines (32 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import express from 'express';
import cors from 'cors';
// Routers
import ptzRouter from './routes/ptz.mjs';
import rtspRouter from './routes/rtsp.mjs';
import atemRouter from './routes/atem.mjs';
import vmixRouter from './routes/vmix.mjs';
import logsRouter from './routes/logs.mjs';
const app = express();
const PORT = 3001;
app.use(express.json()); // Need json body parser for proxy
app.use(cors());
// Prevent crash on unhandled errors
process.on('uncaughtException', (err) => {
console.error('UNCAUGHT EXCEPTION:', err);
});
process.on('unhandledRejection', (reason, p) => {
console.error('UNHANDLED REJECTION:', reason);
});
import hybridRouter from './routes/hybrid.mjs';
app.use('/api/hybrid', hybridRouter);
app.use('/api/ptz', ptzRouter);
app.use('/api/rtsp', rtspRouter);
app.use('/api/atem', atemRouter);
app.use('/api/log', logsRouter);
// Important: vmixRouter has a catch-all '/' proxy, so it must be registered last among API routes.
// Also, the media route is '/media/:key', not '/api/media/:key' in the original file.
app.use('/media', vmixRouter);
app.use('/api', vmixRouter);
app.listen(PORT, '0.0.0.0', () => {
console.log(`vMix Middleware running on http://localhost:${PORT}`);
});