chore: auto-load .env for local backend start/migrate scripts
This commit is contained in:
19
README.md
19
README.md
@@ -23,21 +23,22 @@ pnpm dev:infra
|
|||||||
|
|
||||||
`pnpm dev:infra` starts local PostgreSQL/Redis (see `compose.dev.yml`); `pnpm dev:infra:down` stops them.
|
`pnpm dev:infra` starts local PostgreSQL/Redis (see `compose.dev.yml`); `pnpm dev:infra:down` stops them.
|
||||||
|
|
||||||
Set the required OIDC env vars once per shell before running the backend. **`OIDC_CLIENT_SECRET` is a real secret — set it directly in your own shell, never commit it, never paste it into a shared/logged terminal.** `OIDC_AUDIENCE` should be set to the same value as `OIDC_CLIENT_ID` unless your IdP issues a distinct API audience.
|
Create a **`.env` file at the repository root** (already gitignored, never committed) with the required values. `backend`'s `start:api`/`start:worker`/`migrate` scripts load it automatically via Node's `--env-file-if-exists` — no manual `export` needed. **`OIDC_CLIENT_SECRET` is a real secret — put it only in this local, gitignored file, never in `.env.example`, never pasted into a shared/logged terminal.** `OIDC_AUDIENCE` should be set to the same value as `OIDC_CLIENT_ID` unless your IdP issues a distinct API audience.
|
||||||
|
|
||||||
```bash
|
```dotenv
|
||||||
export DATABASE_URL=postgresql://travel_planner:travel_planner_dev@localhost:5432/travel_planner
|
DATABASE_URL=postgresql://travel_planner:travel_planner_dev@localhost:5432/travel_planner
|
||||||
export REDIS_URL=redis://localhost:6379
|
REDIS_URL=redis://localhost:6379
|
||||||
export OIDC_ISSUER=https://auth.forgecore.work
|
OIDC_ISSUER=https://auth.forgecore.work
|
||||||
export OIDC_CLIENT_ID=client_a297fd8d9c1f47a79d3600ea0c96984
|
OIDC_CLIENT_ID=client_a297fd8d9c1f47a79d3600ea0c96984
|
||||||
export OIDC_AUDIENCE=$OIDC_CLIENT_ID
|
OIDC_AUDIENCE=client_a297fd8d9c1f47a79d3600ea0c96984
|
||||||
export OIDC_CLIENT_SECRET=<your-client-secret> # never commit this value
|
OIDC_CLIENT_SECRET=<your-client-secret>
|
||||||
```
|
```
|
||||||
|
|
||||||
Run pending migrations against the dev database (first time only), then start the API and frontend:
|
Run pending migrations against the dev database (first time only), then start the API and frontend:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm --filter backend build:api && node backend/dist/apps/api/src/migration.js
|
pnpm --filter backend build:api
|
||||||
|
pnpm --filter backend migrate
|
||||||
pnpm --filter backend start:api
|
pnpm --filter backend start:api
|
||||||
pnpm --filter frontend start
|
pnpm --filter frontend start
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
"start": "nest start api",
|
"start": "nest start api",
|
||||||
"start:dev": "nest start api --watch",
|
"start:dev": "nest start api --watch",
|
||||||
"start:debug": "nest start api --debug --watch",
|
"start:debug": "nest start api --debug --watch",
|
||||||
"start:api": "node dist/apps/api/src/main.js",
|
"start:api": "node --env-file-if-exists=../.env dist/apps/api/src/main.js",
|
||||||
"start:worker": "node dist/apps/worker/src/main.js",
|
"start:worker": "node --env-file-if-exists=../.env dist/apps/worker/src/main.js",
|
||||||
|
"migrate": "node --env-file-if-exists=../.env dist/apps/api/src/migration.js",
|
||||||
"lint": "eslint \"{apps,libs}/**/*.ts\" --fix",
|
"lint": "eslint \"{apps,libs}/**/*.ts\" --fix",
|
||||||
"test": "jest --runInBand",
|
"test": "jest --runInBand",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
|
|||||||
Reference in New Issue
Block a user