From 45dfe0f0c69f855132d18e14e0b9b35b2177e1eb Mon Sep 17 00:00:00 2001 From: amel Date: Mon, 29 Jul 2024 12:07:34 +0800 Subject: [PATCH] upd: status respon Deskripsi: - update status respon pada jabatan No Issues --- src/module/position/api/api_position.ts | 16 ++++++++-------- src/module/position/api/get/getAllPosition.ts | 2 +- src/module/position/api/post/createPosition.ts | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/module/position/api/api_position.ts b/src/module/position/api/api_position.ts index 2651eb5..941913f 100644 --- a/src/module/position/api/api_position.ts +++ b/src/module/position/api/api_position.ts @@ -4,12 +4,12 @@ import { API_INDEX_POSITION } from "./api_index"; type Method = "GET" | "POST"; export async function apiPosition(req: NextRequest, method: Method) { - const { searchParams } = new URL(req.url); - const path = searchParams.get("path"); - const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method); - if (!path) - return Response.json({ message: "page not found" }, { status: 404 }); + const { searchParams } = new URL(req.url); + const path = searchParams.get("path"); + const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method); + if (!path) + return Response.json({ success: false, message: "page not found" }, { status: 404 }); if (act) return act.bin(req); - - return Response.json({ message: "404" }); - } \ No newline at end of file + + return Response.json({ success: false, message: "404" }); +} \ No newline at end of file diff --git a/src/module/position/api/get/getAllPosition.ts b/src/module/position/api/get/getAllPosition.ts index 8e57673..b316ae7 100644 --- a/src/module/position/api/get/getAllPosition.ts +++ b/src/module/position/api/get/getAllPosition.ts @@ -19,6 +19,6 @@ export async function getAllPosition(req: NextRequest) { return Response.json(positions); } catch (error) { console.error(error); - return Response.json({ message: "Internal Server Error" }, { status: 500 }); + return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 }); } } diff --git a/src/module/position/api/post/createPosition.ts b/src/module/position/api/post/createPosition.ts index d40f444..35ca42a 100644 --- a/src/module/position/api/post/createPosition.ts +++ b/src/module/position/api/post/createPosition.ts @@ -19,6 +19,6 @@ export async function createlPosition(req: Request) { return Response.json(positions, { status: 201 }); } catch (error) { console.error(error); - return Response.json({ message: "Internal Server Error" }, { status: 500 }); + return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 }); } }