import { t } from "elysia"; /** * Shared `limit`/`offset` query parameters for the list endpoints. * * Every list here is unbounded in principle - a farm accumulates print jobs * forever - so a default limit is applied whether or not the caller asks for * one. `maximum` is enforced by the validator rather than silently clamped: * a client that asks for 10,000 rows should be told no, not handed 200 and * left to conclude that is all there is. */ export const PaginationQuery = { limit: t.Optional(t.Integer({ minimum: 1, maximum: 200, default: 50 })), offset: t.Optional(t.Integer({ minimum: 0, default: 0 })), }; export const DEFAULT_LIMIT = 50; export function paginate(query: { limit?: number; offset?: number }) { return { limit: query.limit ?? DEFAULT_LIMIT, offset: query.offset ?? 0 }; }