INNER CODE UNIT · TypeScript
main
im4codes/imcodes · server/src/index.ts:706
async function main() {
const envConfig = loadEnv();
if (!envConfig.JWT_SIGNING_KEY || Buffer.byteLength(envConfig.JWT_SIGNING_KEY, 'utf8') < 32) {
console.error('FATAL: JWT_SIGNING_KEY must be at least 32 bytes');
process.exit(1);
}
const db = createDatabase(envConfig.DATABASE_URL);
const env: Env = { ...envConfig, DB: db };
const bindHost = env.BIND_HOST ?? '0.0.0.0';
const port = parseInt(env.PORT ?? '19138', 10);
if (bindHost === '0.0.0.0') {
logger.warn({}, 'Server is listening on 0.0.0.0 — ensure TLS is terminated by a reverse proxy');
}
if (!env.ALLOWED_ORIGINS && env.NODE_ENV !== 'development') {