Files
miles c250653961 Add comprehensive test suite for application functionality
- Implement tests for HTTP API endpoints, ensuring correct responses and security headers.
- Create configuration tests to validate loading of defaults and environment overrides.
- Add tests for FEDL service to verify data handling and snapshot functionality.
- Introduce GitHub service tests to check API data normalization and caching behavior.
- Develop monitor service tests for network checks and uptime calculations.
- Implement persistence tests to ensure database migrations are idempotent and data persists across restarts.
- Add vault service tests for session management and brute-force protection mechanisms.
- Include helper functions for test context creation and JSON response handling.
2026-11-08 16:24:06 -06:00

14 lines
467 B
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import Database from 'better-sqlite3';
export function openDatabase(dbPath, { readonly = false } = {}) {
if (!readonly) fs.mkdirSync(path.dirname(dbPath), { recursive: true });
const db = new Database(dbPath, { readonly, fileMustExist: readonly });
db.pragma('journal_mode = WAL');
db.pragma('synchronous = NORMAL');
db.pragma('foreign_keys = ON');
db.pragma('busy_timeout = 5000');
return db;
}