mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-13 07:40:59 +00:00
1ea72dca97
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
17 lines
671 B
TypeScript
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();
|