Skip to content

Commit

Permalink
Check for building to prevent build from failing when dynamic env isn…
Browse files Browse the repository at this point in the history
…'t present
  • Loading branch information
cr0wst committed Dec 29, 2024
1 parent 3bcbc07 commit bf18c59
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/server/db/index.ts
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit bf18c59

Please sign in to comment.