tambah division api index

This commit is contained in:
bipproduction
2024-07-08 12:31:47 +08:00
73 changed files with 2379 additions and 602 deletions

View File

@@ -1,16 +1,13 @@
type Method = "GET" | "POST"
const listApi = [
{
"page": ""
}
]
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 page = searchParams.get("page")
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);
if (!page) return Response.json({ message: "page not found" }, { status: 404 })
return Response.json({ message: "ok" })
}
return Response.json({ message: "404" });
}

View File

@@ -0,0 +1,14 @@
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,
},
];

View File

@@ -0,0 +1,3 @@
export function listProject(req: Request) {
return Response.json({ message: "ini adalah project" })
}

View File

@@ -0,0 +1,3 @@
export async function createProject(req: Request) {
return Response.json({ message: "success create projects" })
}