HL7-1: add comments to code

This commit is contained in:
Markus Thielker 2025-07-30 13:06:17 +02:00
parent ad48df97e5
commit 3898715915
4 changed files with 37 additions and 8 deletions

View file

@ -1,23 +1,25 @@
// define available configurations
interface Config {
port: number;
prefixes: string[];
poolSize: number;
}
// construct config object from environment variables
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),
};
// validate config
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)');
throw new Error('Invalid pool size environment variable (poolSize >= prefix.length)');
}