fix: align ebay route with spec and validate params
This commit is contained in:
@@ -19,10 +19,28 @@ export async function kijijiRoute(req: Request): Promise<Response> {
|
||||
|
||||
const maxPagesParam = reqUrl.searchParams.get("maxPages");
|
||||
const maxPages = maxPagesParam ? parseInt(maxPagesParam, 10) : 5;
|
||||
if (maxPagesParam && Number.isNaN(maxPages)) {
|
||||
return Response.json(
|
||||
{ message: "Invalid maxPages parameter" },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
const priceMinParam = reqUrl.searchParams.get("priceMin");
|
||||
const priceMin = priceMinParam ? parseInt(priceMinParam, 10) : undefined;
|
||||
if (priceMinParam && Number.isNaN(priceMin)) {
|
||||
return Response.json(
|
||||
{ message: "Invalid priceMin parameter" },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
const priceMaxParam = reqUrl.searchParams.get("priceMax");
|
||||
const priceMax = priceMaxParam ? parseInt(priceMaxParam, 10) : undefined;
|
||||
if (priceMaxParam && Number.isNaN(priceMax)) {
|
||||
return Response.json(
|
||||
{ message: "Invalid priceMax parameter" },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
const hideUnstableResults =
|
||||
reqUrl.searchParams.get("unstableFilter") === "true";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user