-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ts
33 lines (26 loc) · 1.13 KB
/
config.ts
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
import * as fs from 'fs';
interface ApplicationConfig {
logLevel: string;
hideLogo: boolean;
}
interface SrtLiveServerConfig {
endpoint: string;
fetchInterval: number;
}
interface WebsocketRelayConfig {
port: number;
path: string;
}
interface Config {
application: ApplicationConfig;
srtLiveServer: SrtLiveServerConfig;
websocketRelay: WebsocketRelayConfig;
}
const config: Config = JSON.parse(fs.readFileSync('./data/config.json', 'utf8'));
config.application.logLevel = process.env.APP_LOG_LEVEL || config.application.logLevel;
config.application.hideLogo = process.env.APP_HIDE_LOGO ? JSON.parse(process.env.APP_HIDE_LOGO) : config.application.hideLogo;
config.srtLiveServer.endpoint = process.env.SRT_LIVE_SERVER_ENDPOINT || config.srtLiveServer.endpoint;
config.srtLiveServer.fetchInterval = parseInt(process.env.SRT_LIVE_SERVER_FETCH_INTERVAL || '', 10) || config.srtLiveServer.fetchInterval;
config.websocketRelay.port = parseInt(process.env.WEBSOCKET_RELAY_PORT || '', 10) || config.websocketRelay.port;
config.websocketRelay.path = process.env.WEBSOCKET_RELAY_PATH || config.websocketRelay.path;
export default config;