Files
sistem-desa-mandiri/src/module/division/api/api_division.ts
2024-07-08 12:31:47 +08:00

14 lines
467 B
TypeScript

import { API_INDEX } from "./api_index";
type Method = "GET" | "POST";
export async function apiDivision(req: Request, method: Method) {
const { searchParams } = new URL(req.url);
const path = searchParams.get("path");
const act = API_INDEX.find((v) => v.path === path && v.method === method);
if (!path)
return Response.json({ message: "page not found" }, { status: 404 });
if (act) return act.bin(req);
return Response.json({ message: "404" });
}