mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 05:05:38 -04:00
Add all 10 milestones: Drizzle ORM + SQLite database with WAL mode, Better Auth email/password authentication, TMDB API integration for search and metadata import, TV season/episode caching, user tracking (watchlist/status/watches/ratings with auto-transitions), discovery feeds (continue watching, library, recommendations), US streaming availability via TMDB providers, background job scheduler with instrumentation hook, and dark cinema-themed frontend with DM Serif Display + DM Sans typography and amber accent design system. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
703 B
TypeScript
23 lines
703 B
TypeScript
import Database from "better-sqlite3";
|
|
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
import * as schema from "./schema";
|
|
|
|
const globalForDb = globalThis as unknown as {
|
|
_db: ReturnType<typeof drizzle> | undefined;
|
|
_sqlite: Database.Database | undefined;
|
|
};
|
|
|
|
if (!globalForDb._sqlite) {
|
|
globalForDb._sqlite = new Database(process.env.DATABASE_URL ?? "sqlite.db");
|
|
globalForDb._sqlite.pragma("journal_mode = WAL");
|
|
globalForDb._sqlite.pragma("foreign_keys = ON");
|
|
globalForDb._sqlite.pragma("busy_timeout = 5000");
|
|
}
|
|
|
|
if (!globalForDb._db) {
|
|
globalForDb._db = drizzle(globalForDb._sqlite, { schema });
|
|
}
|
|
|
|
export const db = globalForDb._db;
|
|
export const sqlite = globalForDb._sqlite;
|