Skip to content

Commit bf18c59

Browse files
committed
Check for building to prevent build from failing when dynamic env isn't present
1 parent 3bcbc07 commit bf18c59

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/server/db/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { drizzle } from 'drizzle-orm/postgres-js';
22
import postgres from 'postgres';
33
import { env } from '$env/dynamic/private';
4+
import { building } from '$app/environment';
45

5-
if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
6-
const client = postgres(env.DATABASE_URL);
6+
if (!env.DATABASE_URL && !building) throw new Error('DATABASE_URL is not set');
7+
const client = postgres(env.DATABASE_URL!);
78
export const db = drizzle(client);

0 commit comments

Comments
 (0)