Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 1x | import { z } from 'zod'
import { DataSchema } from './data'
export const RequestSchema = z.object({
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).default('GET'),
routeKey: z.string().min(1).max(1024),
pathParameters: z.record(z.string(), z.string()).optional(),
queryStringParameters: z.object({
limit: z.string().optional(),
offset: z.string().optional(),
sort: z.string().optional(),
order: z.enum(['asc', 'desc']).optional(),
}).optional(),
headers: z.record(z.string(), z.string()).optional(),
body: z.any().optional(),
})
export type HTTPRequest = z.input<typeof RequestSchema>
const RouteSchema = z.object({
type: z.enum(['route']),
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).default('GET'),
routeKey: z.string().min(1).max(1024).describe('Unique key for the route, e.g. "GET /users/{id}"'),
responseKey: z.string().optional().describe('Key of the data schema to use for the response body'),
description: z.string().optional().describe('Description of the route'),
})
export const ServerSchema = z.object({
type: z.enum(['server']),
routes: z.array(RouteSchema),
data: z.record(z.string(), DataSchema).optional(),
options: z.object({
maxPageSize: z.number().min(1).max(50).optional(),
}).optional(),
})
export type ServerOptions = z.input<typeof ServerSchema>
|