-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverConfig.ts
More file actions
32 lines (27 loc) · 714 Bytes
/
serverConfig.ts
File metadata and controls
32 lines (27 loc) · 714 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
27
28
29
30
31
32
/**
* Server configuration helpers.
*/
interface ServerConfig {
port: number;
host: string;
forceHttps: boolean;
allowedOrigins: string[];
}
/**
* Build server configuration from environment variables.
*/
function getServerConfig(): ServerConfig {
const port = Number(process.env.PORT) || 3001;
const host = process.env.HOST || '0.0.0.0';
const forceHttps = process.env.FORCE_HTTPS === 'true';
const allowedOrigins = process.env.CORS_ORIGINS
? process.env.CORS_ORIGINS.split(',').map((origin) => origin.trim())
: ['http://localhost:3001', 'http://127.0.0.1:3001'];
return {
port,
host,
forceHttps,
allowedOrigins,
};
}
export { getServerConfig, ServerConfig };