first rewrite commit

This commit is contained in:
fuomag9
2025-10-31 20:08:28 +01:00
parent 85d3917f08
commit 315192fb54
605 changed files with 10913 additions and 47794 deletions
+21
View File
@@ -0,0 +1,21 @@
import Database from "better-sqlite3";
import { mkdirSync } from "node:fs";
import { dirname, join } from "node:path";
import { runMigrations } from "./migrations";
const defaultDbPath = join(process.cwd(), "data", "caddy-proxy-manager.db");
const dbPath = process.env.DATABASE_PATH || defaultDbPath;
mkdirSync(dirname(dbPath), { recursive: true });
const db = new Database(dbPath);
db.pragma("journal_mode = WAL");
db.pragma("busy_timeout = 5000");
runMigrations(db);
export default db;
export function nowIso(): string {
return new Date().toISOString();
}