Defining routes
This will be the source of truth of your routes
API
defineRoutes
type DefineRoutes = <T extends Record<string, SharedRoutes>>(routes: T) => TdefineRoute
type DefineRouteParams = {
// method and url are required
method: "get" | "post" | "put" | "patch" | "delete",
url: string // must be a relative ('/something') or absolute url ('https://placeholder.com')
// the following are optionnal, and will be considered void if not provided
requestBodySchema: z.Schema<RequestBody>,
queryParamsSchema: z.Schema<QueryParams>,
headersSchema: z.Schema<Headers>,
responses: {
[statusCode]: z.Schema<Responses>,
}
}Example
Use it where needed
Last updated