Skip to content

Commit ba15c93

Browse files
committed
feat(scripts): add load-fixtures:staging script and support .env.staging in db.ts
1 parent 506a9f4 commit ba15c93

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

drizzle.config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { config } from "dotenv";
22
import type { Config } from "drizzle-kit";
33

4-
const envPath =
5-
process.env.NODE_ENV === "production" ? ".env.production" : ".env.local";
4+
const envPaths = {
5+
production: ".env.production",
6+
staging: ".env.staging",
7+
development: ".env.local",
8+
};
9+
10+
const envPath = envPaths[process.env.NODE_ENV] || ".env.local";
611

712
config({ path: envPath });
813

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"test": "jest",
88
"start": "npx serverless offline",
99
"load-fixtures": "ts-node src/scripts/loadBookFixtures.ts",
10+
"load-fixtures:staging": "NODE_ENV=staging ts-node src/scripts/loadBookFixtures.ts",
1011
"load-fixtures:production": "NODE_ENV=production ts-node src/scripts/loadBookFixtures.ts",
1112
"fetch-covers": "ts-node src/scripts/fetchBookCovers.ts",
1213
"typeorm": "typeorm-ts-node-commonjs"

src/db.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import { drizzle } from "drizzle-orm/node-postgres";
33
import { Client } from "pg";
44
import * as schema from "./schema";
55

6-
const envPath =
7-
process.env.NODE_ENV === "production" ? ".env.production" : ".env.local";
6+
const envPaths = {
7+
production: ".env.production",
8+
staging: ".env.staging",
9+
development: ".env.local",
10+
};
11+
12+
const envPath = envPaths[process.env.NODE_ENV] || ".env.local";
13+
814
config({ path: envPath });
915

1016
export const client = new Client({

0 commit comments

Comments
 (0)