-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (21 loc) · 734 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (21 loc) · 734 Bytes
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
import { createServer } from 'node:http';
import { connectDb } from './src/lib/server/db.js';
import { handler } from './build/handler.js';
import { attachWebSocketServer } from './src/lib/server/rooms.js';
import * as tvRoom from './src/lib/server/tvRoom.js';
process.on('uncaughtException', (err) => {
if (err.code === 'ENOENT' && err.syscall === 'open') {
console.error(`Missing file: ${err.path}`);
return;
}
console.error('Uncaught exception:', err);
process.exit(1);
});
const port = process.env.PORT ?? 3000;
await connectDb();
await tvRoom.init();
const server = createServer(handler);
attachWebSocketServer(server);
server.listen(port, () => {
console.log(`Listening on http://localhost:${port}`);
});