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

2.6.1-beta1

Diff

robintail
published 2.6.0 •

Changelog

Source

v2.6.0

  • Zod version is 3.9.8.
    • It supports the ability to specify the key schema of z.record().
    • In case of using enums and literals in the key schema they will be described as required ones in the generated OpenAPI / Swagger documentation.
// example
z.record(
  z.enum(["option1", "option2"]), // keys
  z.boolean(), // values
);
  • Feature #145: attachRouting() now returns the logger instance and notFoundHandler. You can use it with your custom express app for handling 404 (not found) errors:
const { notFoundHandler } = attachRouting(config, routing);
app.use(notFoundHandler);
app.listen();
  • Or you can use the logger instance with any ResultHandler for the same purpose:
const { logger } = attachRouting(config, routing);
app.use((request, response) => {
  defaultResultHandler.handler({
    request,
    response,
    logger,
    error: createHttpError(404, `${request.path} not found`),
    input: null,
    output: null,
  });
});
app.listen();
robintail
published 2.5.2 •

Changelog

Source

v2.5.2

  • Fixed a bug due to which the API did not respond in case of an error within the ResultHandler.
    • In this case the LastResortHandler comes into play.
    • It sets the status code to 500 and sends out plain text with an error message.
    • It is not customizable yet, and it's meant to be kept very simple in case of JSON conversion errors.
robintail
published 2.5.1 •

Changelog

Source

v2.5.1

  • Fixed a bug due to which the execution of the code could continue despite the possible closing of the response stream by one of the middlewares.
    • Affected Node versions: below 12.9.0.
robintail
published 2.5.0 •

Changelog

Source

v2.5.0

  • New feature: file uploads!
  • The processing of files is provided by express-fileupload which is based on busboy.
  • Introducing the new schema: z.upload().
  • New configuration option:
const config = createConfig({
  server: {
    upload: true,
    // or selected express-fileupload's options:
    // @see https://github.com/richardgirges/express-fileupload#available-options
    upload: {
      uploadTimeout: 60000,
      useTempFiles: true,
      safeFileNames: true,
      preserveExtension: 4,
      tempFileDir: "/var/tmp",
    },
  },
});
  • Creating the Endpoint:
const fileUploadEndpoint = defaultEndpointsFactory.build({
  method: "post",
  type: "upload", // <- new option, required
  input: z.object({
    avatar: z.upload(),
  }),
  output: z.object({
    /* ... */
  }),
  handler: async ({ input: { avatar } }) => {
    // avatar: {name, mv(), mimetype, encoding, data, truncated, size, etc}
    // avatar.truncated is true on failure
    return {
      /* ... */
    };
  },
});
  • The file upload currently supports requests having POST method and multipart/form-data content type.
  • You can send other data and specify additional input parameters, including arrays and objects.
  • Fixed the OPTIONS duplication issue in response header when cors option is enabled:
# before
Access-Control-Allow-Methods: POST, OPTIONS, OPTIONS
# after
Access-Control-Allow-Methods: POST, OPTIONS
robintail
published 1.3.2 •

robintail
published 2.4.0 •

Changelog

Source

v2.4.0

  • Zod version is 3.8.2.
  • Supporting new string format: cuid.
  • Supporting new Zod schema z.preprocess(). Please avoid using it for Endpoint outputs.
  • Supporting default values of optional properties in OpenAPI/Swagger documentation.
// example
z.object({
  name: z.string().optional().default("John Wick"),
});
robintail
published 2.3.3 •

Changelog

Source

v2.3.3

  • Zod version is 3.7.3.
  • Removed usage of the deprecated ZodObject's method .nonstrict() in the example and Readme since it's not required.
robintail
published 2.3.2 •

Changelog

Source

v2.3.2

  • Zod version is 3.7.2.
  • I've also updated it to ^3.7.2 in the package.json file in case of package manager issues.
robintail
published 2.3.1 •

Changelog

Source

v2.3.1

  • Fixed a type mismatch issue when the configuration is declared in a separate file using the ConfigType.
    • ConfigType is now deprecated (will be removed in v3).
    • Please use helper function createConfig().
    • This way it assigns the correct type for using configuration with createServer() and attachRouting().
// before
const configBefore: ConfigType = {
  server: {
    listen: 8090,
  },
  cors: true,
  logger: {
    level: "debug",
    color: true,
  },
};
// after
export const configAfter = createConfig({
  server: {
    listen: 8090,
  },
  cors: true,
  logger: {
    level: "debug",
    color: true,
  },
});
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