api division

Deskripsi:
- api divisi create, update, delete, get one dan get all

No Issues
This commit is contained in:
amel
2024-07-31 15:03:08 +08:00
parent 9d9046127d
commit a0290badfd
11 changed files with 182 additions and 21 deletions

View File

@@ -1,13 +0,0 @@
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" });
}

View File

@@ -1,14 +0,0 @@
import { createProject } from "./post/createProject";
import { listProject } from "./get/listProject";
export const API_INDEX = [
{
path: "create-project",
method: "POST",
bin: createProject,
},
{
path: "list-project",
method: "GET",
bin: listProject,
},
];