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

next-api-middleware

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-api-middleware - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0-canary.0

8

dist/index.d.ts

@@ -0,5 +1,11 @@

/// <reference types="node" />
import type { IncomingMessage, ServerResponse } from "http";
import type { NextApiHandler, NextApiRequest, NextApiResponse } from "next";
export interface Middleware {
export interface NextMiddleware {
(req: NextApiRequest, res: NextApiResponse, next: () => Promise<void>): Promise<void>;
}
export interface ExpressMiddleware<Request = IncomingMessage, Response = ServerResponse> {
(req: Request, res: Response, next: (error?: any) => void | Promise<void>): void;
}
export declare type Middleware = NextMiddleware | ExpressMiddleware;
export interface LabeledMiddleware {

@@ -6,0 +12,0 @@ [name: string]: Middleware | Middleware[];

@@ -53,3 +53,12 @@ "use strict";

return async function finalRouteHandler(req, res) {
const execute = ([currentFn, ...remaining]) => currentFn(req, res, async () => remaining.length === 0 ? apiRouteFn(req, res) : execute(remaining));
const execute = ([currentFn, ...remaining]) => {
return currentFn(req, res, async (err) => {
if (err) {
throw err;
}
return remaining.length === 0
? apiRouteFn(req, res)
: execute(remaining);
});
};
return execute(middlewareFns);

@@ -56,0 +65,0 @@ };

2

package.json
{
"name": "next-api-middleware",
"version": "0.6.0",
"version": "0.7.0-canary.0",
"description": "Middleware solution for Next.js API routes",

@@ -5,0 +5,0 @@ "repository": "git@github.com:htunnicliff/next-api-middleware.git",

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