Initial commit
This commit is contained in:
commit
d9cff2e70c
72 changed files with 2878 additions and 0 deletions
23
packages/server/config.ts
Normal file
23
packages/server/config.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
interface Config {
|
||||
port: number;
|
||||
prefixes: string[];
|
||||
poolSize: number;
|
||||
}
|
||||
|
||||
export const config: Config = {
|
||||
port: parseInt(process.env.PORT || '8080', 10),
|
||||
prefixes: (process.env.PREFIXES || 'STA').split(","),
|
||||
poolSize: parseInt(process.env.POOL_SIZE || '100', 10),
|
||||
};
|
||||
|
||||
if (isNaN(config.port) || config.port < 1024 || config.port > 49151) {
|
||||
throw new Error('Invalid PORT environment variable (1024 - 49151)');
|
||||
}
|
||||
|
||||
if (config.prefixes.length === 0) {
|
||||
throw new Error('Invalid PREFIXES environment variable (length > 1)');
|
||||
}
|
||||
|
||||
if (isNaN(config.poolSize) || config.poolSize < config.prefixes.length) {
|
||||
throw new Error('Invalid PORT environment variable (poolSize >= prefix.length)');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue