2025-06-28 17:07:53 +00:00

48 lines
1023 B
TypeScript

import { DB_PATH } from "$lib/utils/constants";
import { Database, Statement, Statement } from "bun:sqlite";
export class SSLSnifferDatabase {
private static initialized = false
private db: Database
// UGLY: should be more flexible
constructor() {
this.db = SSLSnifferDatabase.initDatabase()
SSLSnifferDatabase.initialized = true
}
// 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)
}
public executeQuery(query: Statement): any {
}
}