-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
list-users.ts
38 lines (37 loc) · 1001 Bytes
/
list-users.ts
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
35
36
37
38
import z from "zod";
import { arrayRespondingFactory } from "../factories";
/**
* This endpoint demonstrates the ability to respond with array.
* Avoid doing this in new projects. This feature is only for easier migration of legacy APIs.
* */
export const listUsersEndpoint = arrayRespondingFactory.build({
tag: "users",
output: z
.object({
// the arrayResultHandler will take the "items" prop as the response
items: z.array(
z.object({
name: z.string(),
}),
),
})
.example({
items: [
{ name: "Hunter Schafer" },
{ name: "Laverne Cox" },
{ name: "Patti Harrison" },
],
}),
handler: async () => ({
items: [
{ name: "Maria Merian" },
{ name: "Mary Anning" },
{ name: "Marie Skłodowska Curie" },
{ name: "Henrietta Leavitt" },
{ name: "Lise Meitner" },
{ name: "Alice Ball" },
{ name: "Gerty Cori" },
{ name: "Helen Taussig" },
],
}),
});