import { NextRequest, NextResponse } from 'next/server'; import { getCachedFirm } from '@/lib/firm-catalog'; import { firmInstruments, instrumentsSource } from '@/lib/instruments'; import { getCredentials } from '@/lib/db'; /** One firm from the cached catalog. Read-only: firms and their account types * are owned by the master dashboard, and there is no local DELETE — a firm * goes away here when it goes away there. */ export async function GET( _req: NextRequest, { params }: { params: Promise<{ id: string }> } ) { const { id } = await params; const firm = getCachedFirm(id); if (!firm) { return NextResponse.json({ error: 'Firm not found' }, { status: 404 }); } const creds = getCredentials(id); return NextResponse.json({ id: firm.id, firm: firm.name, username: creds?.username ?? '', hasCredentials: !!creds, instruments: firmInstruments(firm), instrumentsSource: instrumentsSource(firm), accounts: firm.accountTypes, catalogUpdatedAt: firm.updatedAt, }); }