mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-10-03 05:07:10 +00:00
fix(web): validate ontology pagination (#138)
This commit is contained in:
parent
edf9a1b063
commit
1cfec322ac
6 changed files with 63 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { handle, apiJson } from "@/lib/ontology-service";
|
||||
import { parseBoundedIntegerParam } from "@/lib/pagination";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
|
@ -6,7 +7,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ onto
|
|||
const { ontologyId } = await params;
|
||||
const url = new URL(request.url);
|
||||
const statusParam = url.searchParams.get("status") ?? "asserted";
|
||||
const limit = Math.min(Number(url.searchParams.get("limit") ?? 100), 500);
|
||||
const limit = parseBoundedIntegerParam(url.searchParams.get("limit"), 100, 1, 500);
|
||||
|
||||
return handle(request, ontologyId, (engine) => {
|
||||
const claims = engine.store.listClaims({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { handle, apiJson } from "@/lib/ontology-service";
|
||||
import { parseBoundedIntegerParam } from "@/lib/pagination";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
|
@ -8,8 +9,8 @@ export async function GET(request: Request, { params }: { params: Promise<{ onto
|
|||
const url = new URL(request.url);
|
||||
const type = url.searchParams.get("type") ?? undefined;
|
||||
const q = url.searchParams.get("q") ?? undefined;
|
||||
const limit = Math.min(Number(url.searchParams.get("limit") ?? 50), 200);
|
||||
const offset = Math.max(Number(url.searchParams.get("offset") ?? 0), 0);
|
||||
const limit = parseBoundedIntegerParam(url.searchParams.get("limit"), 50, 1, 200);
|
||||
const offset = parseBoundedIntegerParam(url.searchParams.get("offset"), 0, 0, Number.MAX_SAFE_INTEGER);
|
||||
|
||||
return handle(request, ontologyId, (engine) => {
|
||||
if (q) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { getService, apiError, apiJson, engineFor } from "@/lib/ontology-service";
|
||||
import { parseBoundedIntegerParam } from "@/lib/pagination";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ onto
|
|||
const engine = bound.engine;
|
||||
|
||||
if (!wantsStream) {
|
||||
const limit = Math.min(Number(url.searchParams.get("limit") ?? 100), 500);
|
||||
const limit = parseBoundedIntegerParam(url.searchParams.get("limit"), 100, 1, 500);
|
||||
return apiJson({ events: engine.listEvents({ limit }) });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue