Skip to content

Commit 8b69820

Browse files
chore: add .env support with gitignore protection (#3283)
* chore: add .env support with gitignore protection Add .env/.env.* to gitignore to prevent secret leaks, provide .env.example with all billing env vars, and use Node 22 --env-file flag in start/dev scripts for automatic loading. * fix(scripts): use --env-file-if-exists to avoid crash when .env is absent * fix(chore): keep start/dev scripts without .env, add separate billing scripts start/dev remain unchanged so the app works without Stripe. start:billing/dev:billing load .env for Stripe testing.
1 parent 197768c commit 8b69820

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Stripe Billing
2+
# Get your keys from https://dashboard.stripe.com/test/apikeys
3+
DEVKIT_NODE_stripe_secretKey=sk_test_xxx
4+
DEVKIT_NODE_stripe_webhookSecret=whsec_xxx
5+
6+
# Stripe Price IDs — create products at https://dashboard.stripe.com/test/products
7+
DEVKIT_NODE_stripe_prices_starter_monthly=price_xxx
8+
DEVKIT_NODE_stripe_prices_starter_annual=price_xxx
9+
DEVKIT_NODE_stripe_prices_pro_monthly=price_xxx
10+
DEVKIT_NODE_stripe_prices_pro_annual=price_xxx

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ coverage/
1919

2020
# waos Node app and assets
2121
# ======================
22+
# Environment files (secrets)
23+
.env
24+
.env.*
25+
!.env.example
2226
public/dist/
2327
public/swagger.yml
2428
config/env/local.js

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
},
2525
"scripts": {
2626
"start": "node server.js",
27+
"start:billing": "node --env-file-if-exists=.env server.js",
2728
"dev": "node --watch server.js",
29+
"dev:billing": "node --env-file-if-exists=.env --watch server.js",
2830
"debug": "nodemon --inspect server.js",
2931
"prod": "cross-env NODE_ENV=production node server.js --name=node",
3032
"test": "cross-env NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --runInBand --testPathPatterns='unit'",

0 commit comments

Comments
 (0)