express-zod-api
Advanced tools
Changelog
v22.9.0
Endpoint
using EndpointsFactory::build({ deprecated: true })
;Endpoint::deprecated()
or DependsOnMethod::deprecated()
;ZodType::deprecated()
;.deprecated()
methods are immutable ā they create a new copy of the subject;Documentation
and Integration
;import { Routing, DependsOnMethod } from "express-zod-api";
import { z } from "zod";
const someEndpoint = factory.build({
deprecated: true, // deprecates all routes the endpoint assigned to
input: z.object({
prop: z.string().deprecated(), // deprecates the property or a path parameter
}),
});
const routing: Routing = {
v1: oldEndpoint.deprecated(), // deprecates the /v1 path
v2: new DependsOnMethod({ get: oldEndpoint }).deprecated(), // deprecates the /v2 path
v3: someEndpoint, // the path is assigned with initially deprecated endpoint (also deprecated)
};
Changelog
v22.7.0
Changelog
v22.6.0
Documentation
the examples used to work properly only when assigned to
the top level (z.object().example()
), especially complex scenarios involving path parameters and middlewares;const before = factory.build({
input: z
.object({
key: z.string(),
})
.example({
key: "1234-5678-90",
}),
});
const after = factory.build({
input: z.object({
key: z.string().example("1234-5678-90"),
}),
});
Changelog
v22.5.0
defaultResultHandler
sets headers from HttpError
:
throw createHttpError(400, "message", { headers })
those headers
go to the negative response.405
(Method not allowed) to requests having wrong method:
404
;405
:
wrongMethodBehavior
config option 405
(default: 404
).import { createConfig } from "express-zod-api";
createConfig({ wrongMethodBehavior: 405 });
Changelog
v22.4.2
Changelog
v22.4.1
// reproduction
factory
.addMiddleware({
input: z.object({ query: z.string() }), // ...
})
.build({
input: z.object({ query: z.string() }), // ...
});
type Before = {
query: string;
query: string; // <ā bug #2352
};
type After = {
query: string;
};