New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

next-pipe-middleware

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-pipe-middleware - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

4

dist/index.js

@@ -11,3 +11,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

export const pipeMiddleware = (req, res, middlewares) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
if (middlewares.length === 0) {

@@ -18,3 +17,4 @@ return res;

const [middleware, nextMiddlewareOption] = typeof next === 'function' ? [next, null] : [next[0], next[1]];
if ((_a = nextMiddlewareOption === null || nextMiddlewareOption === void 0 ? void 0 : nextMiddlewareOption.matcher) === null || _a === void 0 ? void 0 : _a.call(nextMiddlewareOption, req.nextUrl.pathname)) {
if ((nextMiddlewareOption === null || nextMiddlewareOption === void 0 ? void 0 : nextMiddlewareOption.matcher) &&
nextMiddlewareOption.matcher(req.nextUrl.pathname) === false) {
return pipeMiddleware(req, res, rest);

@@ -21,0 +21,0 @@ }

{
"name": "next-pipe-middleware",
"version": "0.1.3",
"version": "0.1.4",
"type": "module",

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

# 🧵 Next Pipe Middleware
This is a library for building Next.js middleware declaratively.
You can create highly readable and manageable middleware by piping multiple functions together.

@@ -17,3 +18,3 @@

### Basic
Pass NextRequest, NextResponse, and arrays of multiple middleware (`PipeableMiddleware`) to `pipeMiddleware` function.
Pass NextRequest, NextResponse, and arrays of multiple middleware to `pipeMiddleware` function.

@@ -23,5 +24,5 @@ ```ts

return pipeMiddleware(req, NextResponse.next(), [
FooMiddleware,
BarMiddleware,
HogeMiddleware,
fooMiddleware,
barMiddleware,
hogeMiddleware,
])

@@ -35,3 +36,3 @@ }

const fooMiddleware: PipeableMiddleware = async (req, res) => {
// do something
res.cookies.set('foo', 'bar')
return res;

@@ -41,3 +42,3 @@ };

### 2. Conditional middleware
### Conditional middleware
If you want to control execution of middleware according to the page path, pass an object containing a matcher function as the second element of the tuple

@@ -55,3 +56,3 @@

### 3. Terminable middleware
### Terminable middleware
If you want to terminate the entire process on a particular piece of middleware (i.e., you do not want subsequent pieces of middleware to run), change the response format as follows

@@ -68,3 +69,3 @@

final: true,
}; // terminate process after this middleware by returning object with `final: true` and `res`.
}; // terminate process after this middleware by returning object with `final: true` and `res`
}

@@ -71,0 +72,0 @@ };

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