refactor(server): non-DI islands read env via app-config

This commit is contained in:
jubnl
2026-07-25 15:58:02 +02:00
parent 7f795a2199
commit fb9abdb76c
11 changed files with 64 additions and 71 deletions
+2 -3
View File
@@ -1,4 +1,5 @@
import { WebSocketServer, WebSocket } from 'ws';
import { readEnv } from './app-config';
import { db, canAccessTrip } from './db/database';
import { consumeEphemeralTokenWithMeta } from './services/ephemeralTokens';
import { emitPluginEvent, pluginEventMeta } from './plugin-event-sink';
@@ -31,9 +32,7 @@ const socketMsgCounts = new WeakMap<NomadWebSocket, { count: number; windowStart
/** Attaches a WebSocket server with JWT auth, room-based trip channels, and heartbeat keep-alive. */
function setupWebSocket(server: http.Server): void {
const allowedOrigins = process.env.ALLOWED_ORIGINS
? process.env.ALLOWED_ORIGINS.split(',').map(o => o.trim())
: null;
const allowedOrigins = readEnv().http.wsOrigins;
wss = new WebSocketServer({
server,