- New reporter module that pushes firm stats (total accounts, accounts traded, in trade) to a configurable master dashboard every 30 seconds - Add Instance Name and Dashboard URL fields to the settings page - Register master_dashboard_url and instance_name in settings API - Seed default (empty) values for new settings in db Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
1.0 KiB
TypeScript
32 lines
1.0 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'] 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 });
|
|
}
|
|
}
|