aboutsummaryrefslogtreecommitdiffstats
path: root/packages/api/routes/admin.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-07-12 23:37:52 +0000
committerMohamed Bassem <me@mbassem.com>2025-07-12 23:37:52 +0000
commit1105b4a41b2a91a24a164c70264b294a80afe97b (patch)
tree8b6e695666a3449fa5ff374da16fdff5e7ce738d /packages/api/routes/admin.ts
parentba7a87fe68e18dca53cb21ebd1ff0bab7e3ab414 (diff)
downloadkarakeep-1105b4a41b2a91a24a164c70264b294a80afe97b.tar.zst
feat(api): Expose the update user API in the openapi specs
Diffstat (limited to 'packages/api/routes/admin.ts')
-rw-r--r--packages/api/routes/admin.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/api/routes/admin.ts b/packages/api/routes/admin.ts
new file mode 100644
index 00000000..4b5438d6
--- /dev/null
+++ b/packages/api/routes/admin.ts
@@ -0,0 +1,24 @@
+import { zValidator } from "@hono/zod-validator";
+import { Hono } from "hono";
+
+import { updateUserSchema } from "@karakeep/shared/types/admin";
+
+import { adminAuthMiddleware } from "../middlewares/auth";
+
+const app = new Hono()
+ .use(adminAuthMiddleware)
+
+ // PUT /admin/users/:userId
+ .put("/users/:userId", zValidator("json", updateUserSchema), async (c) => {
+ const userId = c.req.param("userId");
+ const body = c.req.valid("json");
+
+ // Ensure the userId from the URL matches the one in the body
+ const input = { ...body, userId };
+
+ await c.var.api.admin.updateUser(input);
+
+ return c.json({ success: true }, 200);
+ });
+
+export default app;