diff options
Diffstat (limited to 'packages/db/src/index.ts')
| -rw-r--r-- | packages/db/src/index.ts | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index b480f566..9b395ab6 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -1,17 +1,15 @@ import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; import * as schema from "./schema"; +import { keys } from "./keys"; +const { DATABASE_URL } = keys(); // Create a lazy database instance that only initializes when accessed let _db: ReturnType<typeof drizzle> | null = null; function getDb() { - if (!process.env.DATABASE_URL) { - throw new Error("DATABASE_URL is not set"); - } - if (!_db) { - const client = postgres(process.env.DATABASE_URL); + const client = postgres(DATABASE_URL); _db = drizzle(client, { schema }); } |
