From 5101db7fa01621328bb7087c7a2f4e7efb6792c2 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Tue, 6 Feb 2024 11:58:02 +0000 Subject: Start using zod in the API --- lib/types/api/links.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/types/api/links.ts (limited to 'lib/types') diff --git a/lib/types/api/links.ts b/lib/types/api/links.ts new file mode 100644 index 00000000..81cde053 --- /dev/null +++ b/lib/types/api/links.ts @@ -0,0 +1,26 @@ +import { z } from "zod"; + +export const ZBookmarkedLink = z.object({ + id: z.string(), + url: z.string().url(), + createdAt: z.coerce.date(), + + details: z.object({ + title: z.string(), + description: z.string(), + imageUrl: z.string().url(), + }).nullish(), + +}); +export type ZBookmarkedLink = z.infer; + + +// POST /v1/links +export const ZNewBookmarkedLinkRequest = ZBookmarkedLink.pick({ url: true }); + + +// GET /v1/links +export const ZGetLinksResponse = z.object({ + links: z.array(ZBookmarkedLink), +}); +export type ZGetLinksResponse = z.infer; -- cgit v1.2.3-70-g09d2