Prod boot options
Declare mail, KMS, file storage, demo mode, seeds and signal handling as
runProdApp options instead of wiring them by hand in bin/main.ts. Each
option mounts the matching bundled feature, reads its env block and fails
the boot with a clear message when the env is incomplete.
What it shows
Section titled “What it shows”mail:{ transport: "smtp-env" }mountschannel-emailwith an SMTP transport fromSMTP_*and makes the auth mail flows use it."inmemory"is for dev and tests and is rejected in production.kmsMode:"required"builds the KMS adapter and blind-index key fromPLATFORM_KEK,SUBJECT_KEYS_DATABASE_URLandKUMIKO_BLIND_INDEX_KEYand aborts without them."optional"uses them when present.{ plaintextReason }stores PII in plaintext on purpose.fileStorage:{ provider: "auto" }mounts the S3 provider whenS3_BUCKET,S3_REGION,S3_ACCESS_KEYandS3_SECRET_KEYare complete. In production a partial S3 env aborts the boot; in dev it falls back to in-memory storage.demoMode:GET /demo-modepublishes the notice, andreadOnly: trueanswers every write except query and login with403 demo_read_only.signals: SIGTERM and SIGINT runstop()with a drain timeout, then exit 0, or exit 1 on timeout or error.signals: falseleaves the process signals to the host.seeds:{ demoTenant, demoAdminFromEnv, sysadminFromEnv, run }replaces hand-written tenant and admin seeds; needs the auth features (not mounted here).billing:{ stripe: { priceToTier }, defaultTier }mounts the Stripe bridge and the tier-sync webhook route; needsbilling-foundationandtier-engine.
src/app.tslists the features and the boot options.bin/server.tspasses both torunProdApp.- The test boots with
KUMIKO_DRY_RUN_ENV=boot, which runs the full validation and exits before any DB or Redis connection: a complete production env passes, a partial S3 or missing KMS env aborts the boot, and a missingSMTP_HOSTshows up in the env inventory underrunProdApp.mail, because the options add their env blocks to the app’senvSchema.
bun test samples/recipes/prod-boot-optionsSource
Section titled “Source”📄 On GitHub: samples/recipes/prod-boot-options