import { createClient } from '@libsql/client'; import { drizzle } from 'drizzle-orm/libsql'; import * as schema from './schema'; import type { H3Event } from 'h3'; let instance: ReturnType> | undefined; export function useDb(event: H3Event) { if (!instance) { const config = useRuntimeConfig(event); const client = createClient({ url: config.database.url, authToken: config.database.authToken || undefined, }); instance = drizzle(client, { schema }); } return instance; }