From 39b1b5e4168c52d15051d4ea54d1d4c5d83fc024 Mon Sep 17 00:00:00 2001 From: amel Date: Mon, 29 Jul 2024 12:27:01 +0800 Subject: [PATCH] upd: respon api Deskripsi: - update respon api halaman user No Issues --- src/module/user/api/api_user.ts | 16 ++++++++-------- src/module/user/api/get/getAllUser.ts | 2 +- src/module/user/api/post/createUser.ts | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/module/user/api/api_user.ts b/src/module/user/api/api_user.ts index fd90cd6..910df81 100644 --- a/src/module/user/api/api_user.ts +++ b/src/module/user/api/api_user.ts @@ -4,12 +4,12 @@ import { API_INDEX_USER } from "./api_index"; type Method = "GET" | "POST"; export async function apiUser(req: NextRequest, method: Method) { - const { searchParams } = new URL(req.url); - const path = searchParams.get("path"); - const act = API_INDEX_USER.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_USER.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/user/api/get/getAllUser.ts b/src/module/user/api/get/getAllUser.ts index 6182d94..e502c9c 100644 --- a/src/module/user/api/get/getAllUser.ts +++ b/src/module/user/api/get/getAllUser.ts @@ -31,6 +31,6 @@ export async function getAllUser(req: NextRequest) { return Response.json(users); } 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/user/api/post/createUser.ts b/src/module/user/api/post/createUser.ts index e446079..4067556 100644 --- a/src/module/user/api/post/createUser.ts +++ b/src/module/user/api/post/createUser.ts @@ -30,6 +30,6 @@ export async function createUser(req: NextRequest) { return Response.json(users, { status: 200 }); } 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 }); } }