all repos — stealth-developers @ 39b2c861fc0d93f7b3a25e435a4a81241a754800

feat: load config file depending on `NODE_ENV`
willow hai@wlo.moe
Wed, 28 May 2025 17:54:41 +0100
commit

39b2c861fc0d93f7b3a25e435a4a81241a754800

parent

01d2e9fd4ff1d1ff4d424b2b2a5e0719a1cf763a

3 files changed, 14 insertions(+), 5 deletions(-)

jump to
M .gitignore.gitignore

@@ -1,5 +1,6 @@

# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore -.config.json +.config.*json +!.config.example.json # Logs
M README.mdREADME.md

@@ -7,7 +7,7 @@

### requirements - bun - get it here https://bun.sh/ + - get it here https://bun.sh/ - a mongodb database - get it here https://www.mongodb.com/try/download/community

@@ -27,8 +27,12 @@ cd stealth-developers

bun install ``` -configure variables in `.config.json`, copy `.config.example.json` to -`.config.json` and fill in the values. +configure variables in `.config.{ENVIRONMENT}.json`, copy `.config.example.json` +to `.config.json` and fill in the values. + +`ENVIRONMENT` is defined by the `NODE_ENV` environment variable; if not set, it +will default to `DEV`. + ### running
M src/config.tssrc/config.ts

@@ -28,7 +28,11 @@ trelloBoardId: z.string().optional(),

}); function validateConfig() { - const runtimeConfig = JSON.parse(fs.readFileSync(".config.json", "utf8")); + const env = process.env.NODE_ENV || "DEV"; + + const runtimeConfig = JSON.parse( + fs.readFileSync(`.config.${env}.json`, "utf8"), + ); const conf = schema.safeParse(runtimeConfig); if (conf.success) return conf.data;