Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

2.4 KB
Raw Blame
/**
 * registerAs tokens for the BOOT-STABLE values Nest injects, one per namespace
 * in `BOOT_DERIVERS` (src/app-config/boot-derive.ts).
 *
 * A token's factory runs during NestFactory.create(), so the injected object is
 * a SNAPSHOT per built app: integration tests that set env and then build an
 * app get fresh values automatically.
 *
 * Every environment variable has exactly one owner. The variables a token
 * derives are read nowhere else, and `readEnv()` never derives them
 * (tests/unit/app-config/config-ownership.test.ts records both sides and fails
 * on an overlap, and on a token nothing injects). A value that code outside
 * the container needs, or that tests mutate mid-lifetime, stays on
 * `readEnv()` / `RuntimeEnvService` instead.
 *
 * Consumption pattern:
 *   constructor(@Inject(storageConfig.KEY) private readonly storage: ConfigType<typeof storageConfig>) {}
 * or, for the pre-init Express layer in bootstrap.ts, `app.get(httpConfig.KEY)`.
 */
import { BOOT_DERIVERS } from '../../app-config/boot-derive';
import { registerAs } from '@nestjs/config';

/**
 * The pre-init Express layer (trust proxy, HSTS) reads this once per built app
 * through `app.get(httpConfig.KEY)` in bootstrap.ts.
 */
export const httpConfig = registerAs('http', () => BOOT_DERIVERS.http(process.env));
/** The storage registry's conditional place-photo backend (TREK_PLACE_PHOTO_DIR). */
export const storageConfig = registerAs('storage', () => BOOT_DERIVERS.storage(process.env));
/** TransitService's upstream (TRANSIT_API_URL). */
export const transitConfig = registerAs('transit', () => BOOT_DERIVERS.transit(process.env));
/** KitineraryExtractorService's binary probe (KITINERARY_EXTRACTOR_PATH, then PATH). */
export const kitineraryConfig = registerAs('kitinerary', () => BOOT_DERIVERS.kitinerary(process.env));
/**
 * The installation identity towards the liketrek services, their Photon and
 * their Valhalla (TREK_SERVICES, TREK_SERVICES_KEY, TREK_SERVICES_HOSTS,
 * TREK_PHOTON_URL, TREK_VALHALLA_URL).
 */
export const servicesConfig = registerAs('services', () => BOOT_DERIVERS.services(process.env));

/** How the booking mail import takes mail in (MAIL_INGEST_*), each value over its stored setting. */
export const mailIngestConfig = registerAs('mailIngest', () => BOOT_DERIVERS.mailIngest(process.env));

export const BOOT_STABLE_TOKENS = [
  httpConfig,
  storageConfig,
  transitConfig,
  kitineraryConfig,
  servicesConfig,
  mailIngestConfig,
];