express-zod-api
Advanced tools
Changelog
v1.2.1
Routing
objects.createServer
, attachRouting
and new OpenAPI()
may throw an Error in case of using slashes in Routing
keys.Changelog
v1.2.0
// example
const endpoint = endpointsFactory.build({
description: "Here is an example description of the endpoint",
// ...,
});
methods
or method
property to .build()
. This is just a more convenient way for a single method case.// example
const endpoint = endpointsFactory.build({
method: "get", // same as methods:['get'] before
// ...,
});
// example of different I/O schemas for /v1/user
const routing: Routing = {
v1: {
user: new DependsOnMethod({
get: myEndpointForGetAndDelete,
delete: myEndpointForGetAndDelete,
post: myEndpointForPostAndPatch,
patch: myEndpointForPostAndPatch,
}),
},
};
Changelog
v1.0.0
Changelog
v0.7.1
defaultResultHandler
and ResultHandler
calls in server.ts
.Changelog
v0.7.0
// example
const middleware = createMiddleware({
input: z
.object({
one: z.string(),
})
.or(
z.object({
two: z.number(),
}),
),
middleware: async ({ input }) => ({
input, // => type: { one: string } | { two: number }
}),
});
z.transform()
in handler's output schema.// example
const endpoint = factory.build({
methods: ["post"],
input: z.object({}),
output: z.object({
value: z.string().transform((str) => str.length),
}),
handler: async ({ input, options }) => ({
value: "test", // => in response: { value: 4 }
}),
});
EndpointsFactory::constructor()
is now prohibited. Please use .addMiddleware()
and .setResultHandler()
as the right way in order to achieve the correct input schema type in handlers.