feat: integrate @t3-oss/env for environment variable management across the application

This commit is contained in:
tranminhquang
2025-07-15 13:29:16 +07:00
parent 55978c30fa
commit 9d5fb821c7
16 changed files with 118 additions and 37 deletions
+7 -8
View File
@@ -1,17 +1,16 @@
import type { Config } from "drizzle-kit";
import * as dotenv from "dotenv";
import { keys } from "./src/keys";
const { NODE_ENV, DATABASE_URL } = keys();
// Load the right env file based on environment
if (process.env.NODE_ENV === "production") {
if (NODE_ENV === "production") {
dotenv.config({ path: ".env.production" });
} else {
dotenv.config({ path: ".env.local" });
}
if (!process.env.DATABASE_URL) {
throw new Error("DATABASE_URL is not set");
}
export default {
schema: "./src/schema.ts",
dialect: "postgresql",
@@ -19,8 +18,8 @@ export default {
table: "drizzle_migrations",
},
dbCredentials: {
url: process.env.DATABASE_URL,
url: DATABASE_URL,
},
out: "./migrations",
strict: process.env.NODE_ENV === "production",
} satisfies Config;
strict: NODE_ENV === "production",
} satisfies Config;