Initial Commit

This commit is contained in:
2026-10-03 20:07:49 +02:00
commit a1346c98b1
427 changed files with 59320 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
import type { MySql2Database } from 'drizzle-orm/mysql2'
import { drizzle } from 'drizzle-orm/mysql2'
import mysql from 'mysql2/promise'
import * as schema from '../db/schema'
let db: MySql2Database<typeof schema> | undefined
export function useDb() {
if (!db) {
const { databaseUrl } = useRuntimeConfig()
if (!databaseUrl) {
throw createError({ statusCode: 500, statusMessage: 'DATABASE_URL is not configured' })
}
db = drizzle(mysql.createPool(databaseUrl), { schema, mode: 'default' })
}
return db
}