import { pool } from '../pool.js'; // Generic owner-scoped key→jsonb settings store. Used by the speedtest schedule // and (later) the theming panel. Keep values small + JSON-serialisable. export async function get(key, fallback = null) { const { rows } = await pool.query(`SELECT value FROM app_settings WHERE key = $1`, [key]); return rows[0] ? rows[0].value : fallback; } export async function set(key, value) { const { rows } = await pool.query( `INSERT INTO app_settings (key, value, updated_at) VALUES ($1, $2::jsonb, now()) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = now() RETURNING value`, [key, JSON.stringify(value)]); return rows[0].value; }