Files
autofirmer-expanded/app/api/settings/route.ts
T
SenofyandClaude Opus 4.6 f498594b16 Add configurable trading hours setting
Dropdown on settings page with two options:
- Full CME (5:00 PM – 3:00 PM CT) with 5 min buffer
- Equity Hours (8:30 AM – 3:00 PM CT) with 5 min buffer
Setting is read live each tick, no restart needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 19:57:48 -05:00

32 lines
1.1 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { getSetting, setSetting } from '@/lib/db';
const VALID_KEYS = ['max_concurrent_accounts', 'tick_interval_seconds', 'master_dashboard_url', 'instance_name', 'trading_hours'] as const;
type SettingKey = typeof VALID_KEYS[number];
export async function GET() {
const result: Record<string, string | null> = {};
for (const key of VALID_KEYS) {
result[key] = getSetting(key);
}
return NextResponse.json(result);
}
export async function PATCH(req: NextRequest) {
try {
const body = await req.json() as Partial<Record<SettingKey, string | number>>;
for (const key of VALID_KEYS) {
if (key in body) {
const raw = body[key];
if (raw === undefined || raw === null) continue;
setSetting(key, String(raw));
}
}
return NextResponse.json({ ok: true });
} catch (err: any) {
return NextResponse.json({ error: err?.message ?? 'Failed to save settings' }, { status: 500 });
}
}