From 242d8fa2195ee4d7166205131330d6bb604a00c6 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Thu, 30 Apr 2026 11:38:24 +0800 Subject: [PATCH 1/4] fix: allow null for idPosition on edit-user endpoint --- src/app/api/monitoring/[[...slug]]/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/api/monitoring/[[...slug]]/route.ts b/src/app/api/monitoring/[[...slug]]/route.ts index 84c62af..96e4cb4 100644 --- a/src/app/api/monitoring/[[...slug]]/route.ts +++ b/src/app/api/monitoring/[[...slug]]/route.ts @@ -1503,7 +1503,7 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" }) idUserRole: t.String({ description: "ID Role" }), idVillage: t.String({ description: "ID Desa" }), idGroup: t.String({ description: "ID Group" }), - idPosition: t.Optional(t.String({ description: "ID Posisi" })), + idPosition: t.Optional(t.Union([t.String(), t.Null()], { description: "ID Posisi" })), isActive: t.Boolean({ description: "Aktif" }), isWithoutOTP: t.Boolean({ description: "Tanpa OTP" }), }), From 191e3624b87d967089929970256d264d8cc9855a Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Thu, 30 Apr 2026 13:48:12 +0800 Subject: [PATCH 2/4] feat: add API key protection for /api/monitoring endpoints --- .env.example | 6 ++++++ src/app/api/monitoring/[[...slug]]/route.ts | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.env.example b/.env.example index bdd6950..0526ea8 100644 --- a/.env.example +++ b/.env.example @@ -42,6 +42,12 @@ VAPID_PRIVATE_KEY="UHDY8M3-0beVIA2kt2zL3ZeMStJ0j6zVkVd2Cfqpgrc" # API key for file operations (upload, delete, copy, view directory) WS_APIKEY="your-websocket-api-key" +# =========================================== +# MONITORING API +# =========================================== +# API key untuk akses endpoint /api/monitoring (header: x-api-key) +MONITORING_API_KEY="your-monitoring-api-key" + # =========================================== # APPLICATION SETTINGS # =========================================== diff --git a/src/app/api/monitoring/[[...slug]]/route.ts b/src/app/api/monitoring/[[...slug]]/route.ts index 96e4cb4..f3ebf0b 100644 --- a/src/app/api/monitoring/[[...slug]]/route.ts +++ b/src/app/api/monitoring/[[...slug]]/route.ts @@ -25,6 +25,18 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" }) } } })) + .onBeforeHandle(({ request, set, path }) => { + // Docs tidak perlu API key + if (path.startsWith("/api/monitoring/docs")) return; + + const apiKey = process.env.MONITORING_API_KEY; + const incoming = request.headers.get("x-api-key"); + + if (!apiKey || incoming !== apiKey) { + set.status = 401; + return { success: false, message: "Unauthorized" }; + } + }) .get("/grid-overview", async ({ query, set }) => { try { From 705992df452af2685584126282f38a05aa2519af Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Thu, 30 Apr 2026 15:01:28 +0800 Subject: [PATCH 3/4] fix: push to stg branch on build remote instead of main --- .mcp/deploy-stg/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mcp/deploy-stg/server.ts b/.mcp/deploy-stg/server.ts index c3614e7..c84ea4f 100644 --- a/.mcp/deploy-stg/server.ts +++ b/.mcp/deploy-stg/server.ts @@ -197,7 +197,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { // 3. Push to build remote (GitHub) const currentBranch = GIT(["rev-parse", "--abbrev-ref", "HEAD"]); - GIT(["push", "build", `${currentBranch}:main`, "--force"]); + GIT(["push", "build", `${currentBranch}:stg`, "--force"]); // 4. Trigger publish GH([ From fa16c05cde044064c4a3f4831860068915518b13 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Thu, 30 Apr 2026 15:01:47 +0800 Subject: [PATCH 4/4] bump: version 0.1.7 + migration --- package.json | 2 +- prisma/migrations/20260430070147_auto/migration.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20260430070147_auto/migration.sql diff --git a/package.json b/package.json index 9f15aea..c7553a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sistem-desa-mandiri", - "version": "0.1.6", + "version": "0.1.7", "private": true, "scripts": { "dev": "next dev --experimental-https", diff --git a/prisma/migrations/20260430070147_auto/migration.sql b/prisma/migrations/20260430070147_auto/migration.sql new file mode 100644 index 0000000..af5102c --- /dev/null +++ b/prisma/migrations/20260430070147_auto/migration.sql @@ -0,0 +1 @@ +-- This is an empty migration. \ No newline at end of file