express-zod-api
Advanced tools
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;
};
Changelog
v22.4.0
.provide()
method can now accept an additional argument having the type of that context;import { Client, Implementation } from "./generated-client.ts";
interface MyCtx {
extraKey: string;
}
const implementation: Implementation<MyCtx> = async (
method,
path,
params,
ctx, // ctx is optional MyCtx
) => {};
const client = new Client(implementation);
client.provide("get /v1/user/retrieve", { id: "10" }, { extraKey: "123456" });
Changelog
v22.3.1
flush is not a function
having compression
disabled in config;.flush()
method of response
is a feature of compression
(optional peer dependency);compression
is enabled;Changelog
v22.3.0
Subscription
class for consuming Server-sent events:
Integration
can now also generate a frontend helper class Subscription
to ease SSE support;EventSource
instance and exposes it as the public source
property;on
method for your typed listeners;subscriptionClassName
option (default: Subscription
);variant
option set to client
(default).import { Subscription } from "./client.ts"; // the generated file
new Subscription("get /v1/events/stream", {}).on("time", (time) => {});
Changelog
v22.2.0
Middleware::security
declarations:
headers
are enabled within inputSources
of config, the Documentation
generator can now identify them
among other inputs additionally by using the security declarations of middlewares attached to an Endpoint
;x-
prefix.const authMiddleware = new Middleware({
security: { type: "header", name: "token" },
});
Changelog
v22.1.1
security
declarations of the used Middleware
when generating API Documentation
.
Changelog
v22.1.0
clientClassName
for Integration::constructor()
argument, default: Client
.Implementation
previously suggested as an example (using fetch
) became the one used by default;import { Integration } from "express-zod-api";
new Integration({ clientClassName: "FancyClient" });
import { FancyClient } from "./generated-client.ts";
const client = new FancyClient(/* optional implementation */);