From bf18c593d5dbb7b0bbd6657345922eb991e8ba97 Mon Sep 17 00:00:00 2001 From: Steve Crow Date: Sun, 29 Dec 2024 18:34:14 -0500 Subject: [PATCH] Check for building to prevent build from failing when dynamic env isn't present --- src/lib/server/db/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/server/db/index.ts b/src/lib/server/db/index.ts index e4b3c9d..a666c77 100644 --- a/src/lib/server/db/index.ts +++ b/src/lib/server/db/index.ts @@ -1,7 +1,8 @@ import { drizzle } from 'drizzle-orm/postgres-js'; import postgres from 'postgres'; import { env } from '$env/dynamic/private'; +import { building } from '$app/environment'; -if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set'); -const client = postgres(env.DATABASE_URL); +if (!env.DATABASE_URL && !building) throw new Error('DATABASE_URL is not set'); +const client = postgres(env.DATABASE_URL!); export const db = drizzle(client);