Fixed and changes

This commit is contained in:
Akshay Kolli
2026-02-08 03:03:53 -05:00
parent 3f72118348
commit dd1a2ea200
13 changed files with 1948 additions and 125 deletions

39
lib/db.ts Normal file
View File

@@ -0,0 +1,39 @@
import sqlite3 from 'sqlite3';
import { open, Database } from 'sqlite';
let db: Database | null = null;
export async function getDb() {
if (db) return db;
// Enable verbose mode for debugging
sqlite3.verbose();
db = await open({
filename: './dashboard.db',
driver: sqlite3.Database
});
await db.exec(`
CREATE TABLE IF NOT EXISTS uptime_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
service_name TEXT NOT NULL,
url TEXT NOT NULL,
status TEXT NOT NULL,
latency INTEGER,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS visitors (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ip_hash TEXT,
city TEXT,
country TEXT,
lat REAL,
lon REAL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);
`);
return db;
}