diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-05-18 19:12:27 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-05-18 19:12:27 +0000 |
| commit | a5ae67c241d8cdd452acd4d98800ec61740c041f (patch) | |
| tree | f04929b1b27000564d108f25918c6e70fe651fb6 /packages/api/routes | |
| parent | 053d1a905ed6cef71151d168351f22b35ddca986 (diff) | |
| download | karakeep-a5ae67c241d8cdd452acd4d98800ec61740c041f.tar.zst | |
feat(api): Expose the endpoint to create a new tag
Diffstat (limited to 'packages/api/routes')
| -rw-r--r-- | packages/api/routes/tags.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/api/routes/tags.ts b/packages/api/routes/tags.ts index 6d4cf39d..816e58b4 100644 --- a/packages/api/routes/tags.ts +++ b/packages/api/routes/tags.ts @@ -1,7 +1,10 @@ import { zValidator } from "@hono/zod-validator"; import { Hono } from "hono"; -import { zUpdateTagRequestSchema } from "@karakeep/shared/types/tags"; +import { + zCreateTagRequestSchema, + zUpdateTagRequestSchema, +} from "@karakeep/shared/types/tags"; import { authMiddleware } from "../middlewares/auth"; import { adaptPagination, zPagination } from "../utils/pagination"; @@ -16,6 +19,13 @@ const app = new Hono() return c.json(tags, 200); }) + // POST /tags + .post("/", zValidator("json", zCreateTagRequestSchema), async (c) => { + const body = c.req.valid("json"); + const tags = await c.var.api.tags.create(body); + return c.json(tags, 201); + }) + // GET /tags/[tagId] .get("/:tagId", async (c) => { const tagId = c.req.param("tagId"); |
