New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-zod-api

Package Overview
Dependencies
Maintainers
1
Versions
429
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-zod-api - npm Package Versions

13
43

22.4.0

Diff

Changelog

Source

v22.4.0

  • Feat: ability to supply extra data to a custom implementation of the generated client:
    • You can instantiate the client class with an implementation accepting an optional context of your choice;
    • The public .provide() method can now accept an additional argument having the type of that context;
    • The problem on missing such ability was reported by @LucWag.
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" });
robintail
published 22.3.1 •

Changelog

Source

v22.3.1

  • Fixed issue on emitting server-sent events (SSE), introduced in v21.5.0:
    • Emitting SSE failed due to internal error flush is not a function having compression disabled in config;
    • The .flush() method of response is a feature of compression (optional peer dependency);
    • It is required to call the method when compression is enabled;
    • This version fixes the issue by calling the method conditionally;
    • This bug was reported by @bobgubko.
robintail
published 21.11.2 •

robintail
published 22.3.0 •

Changelog

Source

v22.3.0

  • Feat: Subscription class for consuming Server-sent events:
    • The Integration can now also generate a frontend helper class Subscription to ease SSE support;
    • The new class establishes an EventSource instance and exposes it as the public source property;
    • The class also provides the public on method for your typed listeners;
    • You can configure the generated class name using subscriptionClassName option (default: Subscription);
    • The feature is only applicable to the variant option set to client (default).
import { Subscription } from "./client.ts"; // the generated file

new Subscription("get /v1/events/stream", {}).on("time", (time) => {});
robintail
published 22.2.0 •

Changelog

Source

v22.2.0

  • Feat: detecting headers from Middleware::security declarations:
    • When 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;
    • This approach enables handling of custom headers without x- prefix.
const authMiddleware = new Middleware({
  security: { type: "header", name: "token" },
});
robintail
published 22.1.1 •

Changelog

Source

v22.1.1

  • This version contains an important technical simplification of routines related to processing of security declarations of the used Middleware when generating API Documentation.
    • No changes to the operation are expected. This refactoring is required for a feature that will be released later.
robintail
published 22.1.0 •

Changelog

Source

v22.1.0

  • Feat: ability to configure the generated client class name:
    • New option clientClassName for Integration::constructor() argument, default: Client.
  • Feat: default implementation for the generated client:
    • The argument of the generated client class constructor became optional;
    • The Implementation previously suggested as an example (using fetch) became the one used by default;
    • You may no longer need to write the implementation if the default one suits your needs.
import { Integration } from "express-zod-api";
new Integration({ clientClassName: "FancyClient" });
import { FancyClient } from "./generated-client.ts";
const client = new FancyClient(/* optional implementation */);
robintail
published 22.0.0 •

Changelog

Source

v22.0.0

  • Minimum supported Node versions: 20.9.0 and 22.0.0:
    • Node 18 is no longer supported; its end of life is April 30, 2025.
  • BuiltinLogger::profile() behavior changed for picoseconds: expressing them through nanoseconds;
  • Feature: handling all (not just x- prefixed) headers as an input source (when enabled):
    • Behavior changed for headers inside inputSources config option: all headers are addressed to the input object;
    • This change is motivated by the deprecation of x- prefixed headers;
    • Since the order inside inputSources matters, consider moving headers to the first place to avoid overwrites;
    • The generated Documentation recognizes both x- prefixed inputs and well-known headers listed on IANA.ORG;
    • You can customize that behavior by using the new option isHeader of the Documentation::constructor().
  • The splitResponse property on the Integration::constructor() argument is removed;
  • Changes to the client code generated by Integration:
    • The class name changed from ExpressZodAPIClient to just Client;
    • The overload of the Client::provide() having 3 arguments and the Provider type are removed;
    • The public jsonEndpoints const is removed — use the content-type header of an actual response instead;
    • The public type MethodPath is removed — use the Request type instead.
  • The approach to tagging endpoints changed:
    • The tags property moved from the argument of createConfig() to Documentation::constructor();
    • The overload of EndpointsFactory::constructor() accepting config property is removed;
    • The argument of EventStreamFactory::constructor() is now the events map (formerly assigned to events property);
    • Tags should be declared as the keys of the augmented interface TagOverrides instead;
  • The public method Endpoint::getSecurity() now returns an array;
  • Consider the automated migration using the built-in ESLint rule.
// eslint.config.mjs — minimal ESLint 9 config to apply migrations automatically using "eslint --fix"
import parser from "@typescript-eslint/parser";
import migration from "express-zod-api/migration";

export default [
  { languageOptions: { parser }, plugins: { migration } },
  { files: ["**/*.ts"], rules: { "migration/v22": "error" } },
];
  createConfig({
-   tags: {},
    inputSources: {
-     get: ["query", "headers"] // if you have headers on last place
+     get: ["headers", "query"] // move headers to avoid overwrites
    }
  });

  new Documentation({
+   tags: {},
+   isHeader: (name, method, path) => {} // optional
  });

  new EndpointsFactory(
-   { config, resultHandler: new ResultHandler() }
+   new ResultHandler()
  );

  new EventStreamFactory(
-   { config, events: {} }
+   {} // events map only
  );
// new tagging approach
import { defaultEndpointsFactory, Documentation } from "express-zod-api";

// Add similar declaration once, somewhere in your code, preferably near config
declare module "express-zod-api" {
  interface TagOverrides {
    users: unknown;
    files: unknown;
    subscriptions: unknown;
  }
}

// Add extended description of the tags to Documentation (optional)
new Documentation({
  tags: {
    users: "All about users",
    files: { description: "All about files", url: "https://example.com" },
  },
});

Version 21

robintail
published 22.0.0-beta.5 •

robintail
published 21.11.1 •

Changelog

Source

v21.11.1

  • Common styling methods (coloring) are extracted from the built-in logger instance:
    • This measure is to reduce memory consumption when using a child logger.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc