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
0
Versions
430
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-zod-api - npm Package Versions

1
43

21.6.1

Diff

Changelog

Source

v21.6.1

  • node-mocks-http version is ^1.16.2.
robintail
published 21.6.0 •

Changelog

Source

v21.6.0

  • Supporting the following z.string() formats by the Documentation generator:
    • base64 (as byte), date, time, duration, nanoid;
    • And new formats introduced by Zod 3.24: jwt, base64url, cidr;
  • Fixed missing minLength and maxLength properties when depicting z.string().length() (fixed length strings).
robintail
published 21.5.0 •

Changelog

Source

v21.5.0

  • Feat: Introducing Server-Sent Events:
    • Basic implementation of the event streams feature is now available using EventStreamFactory class;
    • The new factory is similar to EndpointsFactory including the middlewares support;
    • Client application can subscribe to the event stream using EventSource class instance;
    • Documentation and Integration do not have yet a special depiction of such endpoints;
    • This feature is a lightweight alternative to Zod Sockets.
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
});
robintail
published 21.4.0 •

Changelog

Source

v21.4.0

  • Return type of public methods getTags() and getScopes() of Endpoint corrected to ReadyonlyArray<string>;
  • Featuring EndpointsFactory::buildVoid() method:
    • It's a shorthand for returning {} while having output schema z.object({});
    • When using this method, handler may return void while retaining the object-based operation internally.
- factory.build({
+ factory.buildVoid({
-   output: z.object({}),
    handler: async () => {
-     return {};
    },
  });
robintail
published 21.3.0 •

Changelog

Source

v21.3.0

  • Fixed provide() method usage example in the code of the generated client;
  • Always splitting the response in the generated client:
    • This will print the positive and negative response types separately;
    • The splitResponse property on the Integration class constructor argument is deprecated.
robintail
published 21.3.0-beta.0 •

robintail
published 21.2.0 •

Changelog

Source

v21.2.0

  • Minor performance adjustments;
  • Introducing stricter overload for the generated ExpressZodAPIClient::provide() method:
    • The method can now also accept two arguments: space-separated method with path and parameters;
    • Using this overload provides strict constraints on the first argument so that undeclared routes can not be used;
    • This design is inspired by the OctoKit and aims to prevent the misuse by throwing a Typescript error.
  • Using ExpressZodAPIClient::provide() with three arguments is deprecated:
    • The return type when using undeclared routes corrected to unknown.
  • The Provider type of the generated client is deprecated;
  • The type of the following generated client entities is corrected so that it became limited to the listed routes:
    • Input, Response, PositiveResponse, NegativeResponse, MethodPath.
- client.provide("get", "/v1/user/retrieve", { id: "10" }); // deprecated
+ client.provide("get /v1/user/retrieve", { id: "10" }); // featured
robintail
published 21.2.0-beta.1 •

robintail
published 21.1.0 •

Changelog

Source

v21.1.0

  • Featuring empty response support:
    • For some REST APIs, empty responses are typical: with status code 204 (No Content) and redirects (302);
    • Previously, the framework did not offer a straightforward way to describe such responses, but now there is one;
    • The mimeType property can now be assigned with null in ResultHandler definition;
    • Both Documentation and Integration generators ignore such entries so that the schema can be z.never():
      • The body of such response will not be depicted by Documentation;
      • The type of such response will be described as undefined (configurable) by Integration.
import { z } from "zod";
import {
  ResultHandler,
  ensureHttpError,
  EndpointsFactory,
  Integration,
} from "express-zod-api";

const resultHandler = new ResultHandler({
  positive: { statusCode: 204, mimeType: null, schema: z.never() },
  negative: { statusCode: 404, mimeType: null, schema: z.never() },
  handler: ({ error, response }) => {
    response.status(error ? ensureHttpError(error).statusCode : 204).end(); // no content
  },
});

new Integration({ noContent: z.undefined() }); // undefined is default
robintail
published 21.1.0-beta.1 •

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