mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-05 07:07:10 +01:00
* Make shared packages the default product foundation * Support the fleet CI runner Node version
13 lines
560 B
TypeScript
13 lines
560 B
TypeScript
import { slidingWindow, toHeaders, type LimitResult } from "limitkit";
|
|
/** App-only budgets; account limits and proxy/recipient keys belong to accountkit. */
|
|
export const limits = {
|
|
ai: slidingWindow({ limit: 20, windowMs: 60 * 60_000 }),
|
|
modelProbe: slidingWindow({ limit: 20, windowMs: 10 * 60_000 }),
|
|
};
|
|
export function tooMany(result: LimitResult): Response {
|
|
return Response.json(
|
|
{ error: "rate_limited", retryAfterSeconds: result.retryAfterSeconds },
|
|
{ status: 429, headers: { ...toHeaders(result), "Cache-Control": "no-store" } },
|
|
);
|
|
}
|