🐛 add env to useDb and apply prettier
tinyedge/deploy Deployed by TinyEdge

This commit is contained in:
2026-08-07 13:28:26 +02:00
parent 67727f96ab
commit cbe1b42f6e
54 changed files with 5492 additions and 2406 deletions
+12 -11
View File
@@ -1,17 +1,18 @@
import { createClient } from '@libsql/client'
import { drizzle } from 'drizzle-orm/libsql'
import * as schema from './schema'
import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import * as schema from './schema';
import type { H3Event } from 'h3';
let instance: ReturnType<typeof drizzle<typeof schema>> | undefined
let instance: ReturnType<typeof drizzle<typeof schema>> | undefined;
export function useDb() {
export function useDb(event: H3Event) {
if (!instance) {
const config = useRuntimeConfig()
const config = useRuntimeConfig(event);
const client = createClient({
url: config.databaseUrl,
authToken: config.databaseAuthToken || undefined,
})
instance = drizzle(client, { schema })
url: config.database.url,
authToken: config.database.authToken || undefined,
});
instance = drizzle(client, { schema });
}
return instance
return instance;
}