import { DB_PATH } from "$lib/utils/constants"; import { Database, Statement } from "bun:sqlite"; export class SSLSnifferApp { private static initialized = false private __db: Database // UGLY: should be more flexible constructor() { this.__db = SSLSnifferApp.initDatabase() SSLSnifferApp.initialized = true } public get db() { return this.__db } // This needs to be static as it doesn't need the object private static initDatabase() { const db = new Database( DB_PATH, { create: true, strict: true } ) // Improve performance db.exec("PRAGMA journal_mode = WAL;"); return db } private closeDatabase(graceful?: boolean) { if (!graceful) { graceful = true } // Change of variable to make it more readable const forceful = !graceful this.db.close(forceful) } }