Make database connection fully lazy to avoid build-time initialization

This commit is contained in:
bitc0de committed 2025-12-17 15:42:04 +01:00
1 parent 3169fa815e
commit e86d4d7d60
8 files changed
+18 -10

No files matched your search

+2 -1
View File
@@ -1,5 +1,5 @@
import { NextRequest, NextResponse } from 'next/server'
import db from '@/lib/db'
import { getDb } from '@/lib/db'
import { getStreamUrl } from '@/lib/ytdlp'
import { streamCache } from '@/lib/cache'
@@ -11,6 +11,7 @@ export async function GET(
const { id } = await params
// Get song from database
const db = getDb()
const song = db.prepare('SELECT * FROM songs WHERE id = ?').get(id) as any
if (!song) {