feat(api): BIT-2601 rate-limit typing, login preset, and rejection metrics
CI / Test ingest-api (push) Has been cancelled
CI / Test api (push) Has been cancelled
CI / Lint and typecheck admin-ui (push) Has been cancelled
CI / Validate Docker build (push) Has been cancelled

Align hub rate-limit error context with @fastify/rate-limit types, parse RATE_*
and body-size env vars via parsePositiveIntEnv, wire POST /admin/auth/login to
the login preset, increment er_api_rate_limit_rejections_total per bucket, and
document ingest_token_id plus Prometheus scraping notes.

Made-with: Cursor
This commit is contained in:
David Santos committed 2026-04-12 11:29:31 +00:00
1 parent 6c22dc8bb9
commit b29f72bef4
9 files changed
+155 -58

No files matched your search

+1
View File
@@ -35,6 +35,7 @@ export default async function adminAuthRoutes(app: FastifyInstance): Promise<voi
app.post<{ Body: LoginBody }>(
'/admin/auth/login',
{
config: { rateLimit: app.rateLimits.login },
schema: {
body: {
type: 'object',
@@ -50,9 +50,11 @@ async function buildApp(pool?: ReturnType<typeof makePool>): Promise<FastifyInst
app.decorate('db', p as unknown as FastifyInstance['db']);
app.decorate('auditLog', vi.fn().mockResolvedValue(undefined));
app.decorate('rateLimits', {
ingest: {}, login: {}, global: {},
ingest: { max: 1000, timeWindow: 60_000 },
login: { max: 10, timeWindow: 300_000 },
global: { max: 500, timeWindow: 60_000 },
mutation: { max: 100, timeWindow: 60_000 },
} as unknown as FastifyInstance['rateLimits']);
});
await app.register(errorMonitoringMutationsRoutes);
return app;