diff options
| author | MohamedBassem <me@mbassem.com> | 2024-02-06 11:58:02 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-02-06 11:58:02 +0000 |
| commit | 5101db7fa01621328bb7087c7a2f4e7efb6792c2 (patch) | |
| tree | c5054290306b0d575bc98471f530bef543bbba82 /lib | |
| parent | e5b79e8ff0de22f86387a46c2155044adeb19fc4 (diff) | |
| download | karakeep-5101db7fa01621328bb7087c7a2f4e7efb6792c2.tar.zst | |
Start using zod in the API
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/types/api/links.ts | 26 |
1 files changed, 26 insertions, 0 deletions
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<typeof ZBookmarkedLink>; + + +// 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<typeof ZGetLinksResponse>; |
