Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-app

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-app - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

2

package.json
{
"name": "async-app",
"version": "4.4.0",
"version": "4.5.0",
"description": "An express wrapper for handling async middlewares, order middlewares, schema validator, and other stuff",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -17,3 +17,3 @@ "use strict";

});
const createMiddleware = (validate, generateError, source) => (req, res, next) => {
const createMiddleware = (validate, generateError, source, context) => (req, res, next) => {
const realSource = source || METHOD_SOURCE_MAP[req.method.toLowerCase()];

@@ -23,3 +23,3 @@ const data = req[realSource];

if (schemaErrors.length) {
res.status(400).send(generateError(schemaErrors, realSource));
res.status(400).send(generateError(schemaErrors, realSource, Object.assign({}, context, { req })));
return;

@@ -38,3 +38,3 @@ }

return middlewares;
const schemaMiddleware = createMiddleware(compileSchema(schema.$schema || schema, context), generateError, source);
const schemaMiddleware = createMiddleware(compileSchema(schema.$schema || schema, context), generateError, source, context);
schemaMiddleware.$noOrder = true;

@@ -41,0 +41,0 @@ return [schemaMiddleware, ...middlewares];

@@ -7,2 +7,5 @@ import { Express, NextFunction, Request, Response } from 'express';

}
export interface ErrorContext extends Context {
req: Request;
}
export interface Entities {

@@ -52,3 +55,3 @@ _: unknown;

export declare type CompileSchema<T> = (schema: Schema<T>, context: Context) => ValidateSchema;
export declare type GenerateSchemaErrorFn = (errors: ValidationError[], source: string) => any;
export declare type GenerateSchemaErrorFn = (errors: ValidationError[], source: string, context: ErrorContext) => any;
export declare type ErrorHandlerFn<TEntities extends Entities> = (errors: CustomError, req: Req<TEntities, keyof TEntities>, res: Response, next: NextFunction) => any;

@@ -55,0 +58,0 @@ export declare type MiddlewareArg<TEntities extends Entities> = CommonMiddleware<TEntities> | CommonMiddleware<TEntities>[] | AsyncMiddleware<TEntities>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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