summaryrefslogtreecommitdiff
path: root/lib/schemas.ts
blob: 669674a69ad0e56d7cbe38a6ac8d37f0d154c87b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { z } from "@hono/zod-openapi";

const ErrorResponse = z.string().optional().openapi({
	description: "Error message reported by server",
});

const TeawieURLResponse = z.object({
	url: z.string().url().optional().openapi({
		description: "URL to Teawie",
	}),

	error: ErrorResponse,
});

export const ListTeawiesParams = z.object({
	limit: z
		.string()
		.optional()
		.default("5")
		.refine((data) => {
			const parsed = parseInt(data);
			return !isNaN(parsed);
		})
		.openapi({
			description: "Maximum number of Teawie URLs to be returned",
		}),
});

export const ListTeawiesResponse = z.object({
	urls: z.array(z.string().url()).optional(),
	error: ErrorResponse,
});

export const RandomTeawiesResponse = TeawieURLResponse;