Files
TREK/server/src/nest/app-config/app-config.module.ts
T
Maurice 724c88c201 style: format server and shared with prettier
A mechanical prettier --write over server/src, server/tests, server/scripts
and shared/src with the workspaces' .prettierrc; nothing but layout and
import order changes, and every file keeps the same set of imports. shared
is formatted throughout and its format baseline is empty. The server
baseline keeps the 35 files that Prettier would grow past their lint:size
limit (they need a split first, which is not a formatting change), and the
generated entity files stay as their generator writes them.
2026-10-10 21:23:37 +02:00

40 lines
1.6 KiB
TypeScript

/**
* Global binding of @nestjs/config onto TREK's app-config layer.
*
* INVARIANTS — breaking either silently breaks ~60 env-mutating tests:
* - `cache: false`, always. `cache: true` would freeze ConfigService lookups
* for the whole app lifetime; the runtime-toggled vars (DEMO_MODE, NODE_ENV,
* OIDC_*, …) must stay live via RuntimeEnvService/readEnv().
* - No `validate`/`validationSchema` here. Fail-fast validation runs exactly
* once, from the production entrypoint (src/app-config/boot-validate.ts) —
* buildApp() is invoked dozens of times per test run and must stay
* side-effect-free.
* - `ignoreEnvFile: true`, always. dotenv is loaded ONCE in index.ts; tests
* deliberately never load .env, and reading it here would leak a
* developer's local server/.env into every integration test.
*
* The framework's ConfigModule is aliased ONLY inside this file: app.module.ts
* already imports a local `ConfigModule` (the /api/config endpoint module), so
* the alias keeps the two from colliding anywhere else.
*/
import { DataPathsService } from './data-paths.service';
import { RuntimeEnvService } from './runtime-env.service';
import { BOOT_STABLE_TOKENS } from './tokens';
import { Global, Module } from '@nestjs/common';
import { ConfigModule as NestConfigModule } from '@nestjs/config';
@Global()
@Module({
imports: [
NestConfigModule.forRoot({
isGlobal: true,
ignoreEnvFile: true,
cache: false,
load: BOOT_STABLE_TOKENS,
}),
],
providers: [RuntimeEnvService, DataPathsService],
exports: [RuntimeEnvService, DataPathsService],
})
export class AppConfigModule {}