feat: Migrate Arbiter and Modpack Version Checker to monorepo
WHAT WAS DONE: - Migrated Arbiter (discord-oauth-arbiter) code to services/arbiter/ - Migrated Modpack Version Checker code to services/modpack-version-checker/ - Created .env.example for Arbiter with all required environment variables - Moved systemd service file to services/arbiter/deploy/ - Organized directory structure per Gemini monorepo recommendations WHY: - Consolidate all service code in one repository - Prepare for Gemini code review (Panel v1.12 compatibility check) - Enable service-prefixed Git tagging (arbiter-v2.1.0, modpack-v1.0.0) - Support npm workspaces for shared dependencies SERVICES MIGRATED: 1. Arbiter (Discord OAuth bot) - Originally written by Gemini + Claude - Full source code from ops-manual docs/implementation/ - Created comprehensive .env.example - Ready for Panel v1.12 compatibility verification 2. Modpack Version Checker (Python CLI tool) - Full source code from ops-manual docs/tasks/ - Written for Panel v1.11, needs Gemini review for v1.12 - Never had code review before STILL TODO: - Whitelist Manager - Pull from Billing VPS (38.68.14.188) - Currently deployed and running - Needs Panel v1.12 API compatibility fix (Task #86) - Requires SSH access to pull code NEXT STEPS: - Gemini code review for Panel v1.12 API compatibility - Create package.json for each service - Test npm workspaces integration - Deploy after verification FILES: - services/arbiter/ (25 new files, full application) - services/modpack-version-checker/ (21 new files, full application) Signed-off-by: The Golden Chronicler <claude@firefrostgaming.com>
This commit is contained in:
46
services/arbiter/src/database.js
Normal file
46
services/arbiter/src/database.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// src/database.js
|
||||
// SQLite database initialization and maintenance for Firefrost Arbiter
|
||||
|
||||
const Database = require('better-sqlite3');
|
||||
const db = new Database('linking.db');
|
||||
|
||||
// Create tables if they don't exist
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS link_tokens (
|
||||
token TEXT PRIMARY KEY,
|
||||
email TEXT NOT NULL,
|
||||
tier TEXT NOT NULL,
|
||||
subscription_id TEXT NOT NULL,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
used INTEGER DEFAULT 0
|
||||
)
|
||||
`);
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS audit_logs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
admin_id TEXT NOT NULL,
|
||||
target_user TEXT NOT NULL,
|
||||
action TEXT NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
`);
|
||||
|
||||
// Cleanup function - removes tokens older than 24 hours
|
||||
function cleanupExpiredTokens() {
|
||||
const stmt = db.prepare(`
|
||||
DELETE FROM link_tokens
|
||||
WHERE created_at < datetime('now', '-1 day')
|
||||
`);
|
||||
const info = stmt.run();
|
||||
console.log(`[Database] Cleaned up ${info.changes} expired tokens.`);
|
||||
}
|
||||
|
||||
// Run cleanup once every 24 hours (86400000 ms)
|
||||
setInterval(cleanupExpiredTokens, 86400000);
|
||||
|
||||
// Run cleanup on startup to clear any that expired while app was down
|
||||
cleanupExpiredTokens();
|
||||
|
||||
module.exports = db;
|
||||
Reference in New Issue
Block a user