feat: tambah endpoint GET /api-keys/:id untuk ambil full key
This commit is contained in:
@@ -1448,6 +1448,20 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
detail: { summary: "List API Keys", tags: ["api-key"] },
|
||||
})
|
||||
|
||||
.get("/api-keys/:id", async ({ params, set }) => {
|
||||
try {
|
||||
const key = await prisma.apiKey.findUnique({ where: { id: params.id } });
|
||||
if (!key) { set.status = 404; return { success: false, message: "API key tidak ditemukan" }; }
|
||||
return { success: true, data: key };
|
||||
} catch (error) {
|
||||
set.status = 500;
|
||||
return { success: false, message: "Gagal mendapatkan API key" };
|
||||
}
|
||||
}, {
|
||||
params: t.Object({ id: t.String() }),
|
||||
detail: { summary: "Get API Key (full)", tags: ["api-key"] },
|
||||
})
|
||||
|
||||
.post("/api-keys", async ({ body, set }) => {
|
||||
try {
|
||||
const rawKey = "ak_" + crypto.randomUUID().replace(/-/g, "");
|
||||
|
||||
Reference in New Issue
Block a user