Skip to content

Commit

Permalink
Apply MAX_LIMIT configuration option to limit
Browse files Browse the repository at this point in the history
  • Loading branch information
0237h committed Jun 21, 2024
1 parent 4f248e3 commit 876871e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import openapi from "./tsp-output/@typespec/openapi3/openapi.json";
import { Hono } from "hono";
import { ZodBigInt, ZodBoolean, ZodDate, ZodDefault, ZodNumber, ZodOptional, ZodTypeAny, ZodUndefined, ZodUnion, z } from "zod";
import { EndpointByMethod } from './src/types/zod.gen.js';
import { APP_VERSION } from "./src/config.js";
import { APP_VERSION, config } from "./src/config.js";
import { logger } from './src/logger.js';
import * as prometheus from './src/prometheus.js';
import { makeUsageQuery } from "./src/usage.js";
Expand Down Expand Up @@ -96,6 +96,8 @@ function AntelopeTokenAPI() {
// Query and path user input parameters come as strings and we need to coerce them to the right type using Zod
if (underlying_zod_type instanceof ZodNumber) {
p[key] = z.coerce.number();
if (key === "limit")
p[key] = p[key].max(config.maxLimit);
} else if (underlying_zod_type instanceof ZodBoolean) {
p[key] = z.coerce.boolean();
} else if (underlying_zod_type instanceof ZodBigInt) {
Expand Down

0 comments on commit 876871e

Please sign in to comment.