Persist one browser user agent for Axios and WebSockets

This commit is contained in:
Brandon Li
2026-10-19 06:08:23 -05:00
parent 13e03c3d0f
commit ed56e306d1
21 changed files with 380 additions and 64 deletions
+12
View File
@@ -389,6 +389,18 @@ export function setSetting(key: string, value: string): void {
db.prepare(`INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`).run(key, value);
}
/** Seed a generated setting once, including across simultaneous server workers.
* Acquire the write lock before reading so they cannot choose different values. */
export function getOrCreateSetting(key: string, create: () => string): string {
return db.transaction(() => {
const saved = getSetting(key);
if (saved?.trim()) return saved;
const value = create();
setSetting(key, value);
return value;
}).immediate();
}
// ── Instruments ──────────────────────────────────────────────────────────────
const SYMBOLS = ['NQ','MNQ','ES','MES','YM','MYM','RTY','M2K','GC','MGC','SI','CL','MCL','NG','ZB','ZN','ZF','6E','6J','6B'];