express-zod-api
Advanced tools
Changelog
v21.7.0
EncodedResponse
public interface in the code generated by Integration
:
Response
and EndcodedResponse
is the second hierarchical level.import { EncodedResponse } from "./generated.ts";
type UsageExample = EncodedResponse["get /v1/user/retrieve"][200];
Changelog
v21.6.1
node-mocks-http
version is ^1.16.2
;Path
type generated by Integration
:
DependsOnMethod
instance within specified routing
.Changelog
v21.6.0
z.string()
formats by the Documentation
generator:
base64
(as byte
), date
, time
, duration
, nanoid
;jwt
, base64url
, cidr
;minLength
and maxLength
properties when depicting z.string().length()
(fixed length strings).Changelog
v21.5.0
EventStreamFactory
class;EndpointsFactory
including the middlewares support;EventSource
class instance;Documentation
and Integration
do not have yet a special depiction of such endpoints;import { z } from "zod";
import { EventStreamFactory } from "express-zod-api";
import { setTimeout } from "node:timers/promises";
const subscriptionEndpoint = EventStreamFactory({
events: { time: z.number().int().positive() },
}).buildVoid({
input: z.object({}), // optional input schema
handler: async ({ options: { emit, isClosed } }) => {
while (!isClosed()) {
emit("time", Date.now());
await setTimeout(1000);
}
},
});
const source = new EventSource("https://example.com/api/v1/time");
source.addEventListener("time", (event) => {
const data = JSON.parse(event.data); // number
});
Changelog
v21.4.0
getTags()
and getScopes()
of Endpoint
corrected to ReadyonlyArray<string>
;EndpointsFactory::buildVoid()
method:
{}
while having output
schema z.object({})
;handler
may return void
while retaining the object-based operation internally.- factory.build({
+ factory.buildVoid({
- output: z.object({}),
handler: async () => {
- return {};
},
});
Changelog
v21.3.0
provide()
method usage example in the code of the generated client;splitResponse
property on the Integration
class constructor argument is deprecated.Changelog
v21.2.0
ExpressZodAPIClient::provide()
method:
ExpressZodAPIClient::provide()
with three arguments is deprecated:
unknown
.Provider
type of the generated client is deprecated;Input
, Response
, PositiveResponse
, NegativeResponse
, MethodPath
.- client.provide("get", "/v1/user/retrieve", { id: "10" }); // deprecated
+ client.provide("get /v1/user/retrieve", { id: "10" }); // featured