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
432
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
44

21.0.0-beta.3

Diff

robintail
published 20.21.1 •

Changelog

Source

v20.21.1

  • Performance tuning: Routing traverse made about 12 times faster.
robintail
published 21.0.0-beta.2 •

robintail
published 20.21.0 •

Changelog

Source

v20.21.0

  • Feat: input schema made optional:
    • The input property can be now omitted on the argument of the following methods: Middlware::constructor, EndpointsFactory::build(), EndpointsFactory::addMiddleware();
    • When the input schema is not specified z.object({}) is used;
    • This feature aims to simplify the implementation for Endpoints and Middlwares having no inputs.
robintail
published 20.21.0-beta.1 •

robintail
published 20.20.1 •

Changelog

Source

v20.20.1

  • Minor code style refactoring and performance tuning;
  • The software is redefined as a framework;
    • Thanks to @JonParton for contribution to the documentation.
robintail
published 20.20.0 •

Changelog

Source

v20.20.0

  • Introducing errorHandler option for testMiddleware() method:
    • If your middleware throws an error there was no ability to make assertions other than the thrown error;
    • New option can be assigned with a function for transforming the error into response, so that testMiddlware itself would not throw, enabling usage of all returned entities for mutiple assertions in test;
    • The feature suggested by @williamgcampbell.
import { testMiddleware, Middleware } from "express-zod-api";

const middlware = new Middleware({
  input: z.object({}),
  handler: async ({ logger }) => {
    logger.info("logging something");
    throw new Error("something went wrong");
  },
});

test("a middleware throws, but it writes log as well", async () => {
  const { loggerMock, responseMock } = await testMiddleware({
    errorHandler: (error, response) => response.end(error.message),
    middleware,
  });
  expect(loggerMock._getLogs().info).toEqual([["logging something"]]);
  expect(responseMock._getData()).toBe("something went wrong");
});
robintail
published 20.19.0 •

Changelog

Source

v20.19.0

  • Configuring built-in logger made optional:
    • Built-in logger configuration option level made optional as well as the logger option for createConfig();
    • Using debug level by default, or warn when NODE_ENV=production.
  • Fixed performance issue on BuiltinLogger when its color option is not set in config:
    • .child() method is 50x times faster now by only detecting the color support once;
    • Color autodetection was introduced in v18.3.0.
robintail
published 20.18.0 •

Changelog

Source

v20.18.0

  • Introducing ensureHttpError() method that converts any Error into HttpError:
    • It converts InputValidationError to BadRequest (status code 400) and others to InternalServerError (500).
  • Deprecating getStatusCodeFromError() — use the ensureHttpError().statusCode instead.
  • Generalizing server-side error messages in production mode by default:
    • This feature aims to improve the security of your API by not disclosing the exact causes of errors;
    • Applies to defaultResultHandler, defaultEndpointsFactory and Last Resort Handler only;
    • When NODE_ENV is set to production (displayed on startup);
    • Instead of actual message the default one associated with the corresponding statusCode used;
    • Server-side errors are those having status code 5XX, or treated that way by ensureHttpError();
    • You can control that behavior by throwing errors using createHttpError() and using its expose option;
    • More about production mode and how to activate it: https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production
import createHttpError from "http-errors";
// NODE_ENV=production
// Throwing HttpError from Endpoint or Middleware that is using defaultResultHandler or defaultEndpointsFactory:
createHttpError(401, "Token expired"); // —> "Token expired"
createHttpError(401, "Token expired", { expose: false }); // —> "Unauthorized"
createHttpError(500, "Something is broken"); // —> "Internal Server Error"
createHttpError(501, "We didn't make it yet", { expose: true }); // —> "We didn't make it yet"
robintail
published 20.18.0-beta.2 •

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