flatten app to repo root and update docker deployment for single-stack runtime
This commit is contained in:
22
app/api/filings/route.ts
Normal file
22
app/api/filings/route.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { getStoreSnapshot } from '@/lib/server/store';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const url = new URL(request.url);
|
||||
const tickerFilter = url.searchParams.get('ticker')?.trim().toUpperCase();
|
||||
const limitValue = Number(url.searchParams.get('limit') ?? 50);
|
||||
const limit = Number.isFinite(limitValue)
|
||||
? Math.min(Math.max(Math.trunc(limitValue), 1), 250)
|
||||
: 50;
|
||||
|
||||
const snapshot = await getStoreSnapshot();
|
||||
const filtered = tickerFilter
|
||||
? snapshot.filings.filter((filing) => filing.ticker === tickerFilter)
|
||||
: snapshot.filings;
|
||||
|
||||
const filings = filtered
|
||||
.slice()
|
||||
.sort((a, b) => Date.parse(b.filing_date) - Date.parse(a.filing_date))
|
||||
.slice(0, limit);
|
||||
|
||||
return Response.json({ filings });
|
||||
}
|
||||
Reference in New Issue
Block a user