···11+import { drizzle } from 'drizzle-orm/postgres-js';
22+import postgres from 'postgres';
33+import { env } from '$env/dynamic/private';
44+import * as schema from "../schema";
55+66+if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
77+const client = postgres(env.DATABASE_URL);
88+99+// add schema
1010+export const db = drizzle(client, { schema });
···11+import type { ServerLoadEvent } from "@sveltejs/kit";
22+33+export async function load({ locals }: ServerLoadEvent) {
44+ // have user available throughout the app via LayoutData
55+ return { user: locals.user };
66+}