Files
TREK/server/src/app-config/boot-validate.ts
T
Maurice 1ea72dca97 fix(config): trim whitespace around NODE_ENV, LOG_LEVEL and DEFAULT_LANGUAGE once at boot
NODE_ENV="production " passed the boot check but matched none of the
exact production comparisons, so the web UI was never served and every
page answered {"error":"Cannot GET /"}, while the banner showed a clean
"production". The boot import now trims these three variables in
process.env before anything else reads them, so Express, the plugin
children and readEnv() agree, and reports each change as a process
warning. Casing stays as it was. A padded "test" is only reported, so an
instance cannot switch to an in-memory database after an update. The
banner prints NODE_ENV as set instead of lowercasing it.

Refs #2565
2026-10-12 09:27:19 +02:00

17 lines
671 B
TypeScript

/**
* Side-effect module: normalizes and validates the environment the moment it
* is imported.
*
* index.ts imports this immediately after `import 'dotenv/config'` — as a
* side-effect import (not a function call) so validation runs BEFORE the rest
* of the import graph executes its module-load side effects (config.ts key
* resolution, ...). A plain call in index.ts's body
* would run after all of those, because imports hoist. The trim runs first,
* so everything after it, Express and the plugin children included, reads the
* cleaned value.
*/
import { normalizeEnvAtBoot, validateEnvAtBoot } from './env';
normalizeEnvAtBoot();
validateEnvAtBoot();