
Research
Shai-Hulud Descends to Hades: Miasma Worm Campaign Spreads with New PyPI Wave
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.
next-middleware-list
Advanced tools
This package allows you to separate your middleware into multiple files instead of having one big mono-middleware file.
This package allows you to separate your middleware into multiple files instead of having one big mono-middleware file.
It works by having a config file, with an array of middlwares (.js/.ts files) to be ran per request in the order they are defined within the config file.
install:
npm i next-middleware-list
middlewares.config.ts file either in the root or src directoryimport { MiddlewareListConfig } from "next-middleware-list"
export const middlewareConfig: MiddlewareListConfig = []
middleware.ts fileCreate a middleware.ts file either in the root or src directory and put the following code into it:
import { withMiddlewareList } from 'next-middleware-list'
import { middlewareConfig } from '...' // replace `...` with the path to your `middlewares.config.ts` file
export default withMiddlewareList(middlewareConfig)
Create a file, for example withExample.ts. The file should export a function with 2 arguements (request, response) as follows:
import { NextRequest, NextResponse } from "next/server";
export async function withExample(request:NextRequest, response:NextResponse) {
console.log("withExample")
}
Now in your middlewares.config.ts file modify it as follows:
import { MiddlewareListConfig } from "next-middleware-list"
import { withExample } from "..." // replace `...` with the path to your middleware file (for example `withExample.ts`)
export const middlewareConfig: MiddlewareListConfig = [
[withExample, "*"]
]
Each middleware inside of the config are only ran if the url of the request matches one or more of its matchers.
If the matchers for a given middleware is "*" then it will be ran on every request.
Matchers are formatted as follows:
{
relMatchers: [...],
absMatchers: [...],
}
relMatchers match to the relative url of the request (path name) whereas absMatchers match to the absolute url of the request (entire url).
All items inside of relMatchers and absMatchers must either be a string or a regex.
create a new file called withAuth.ts and add this code to it:
import { withAuth } from "next-auth/middleware"
export default withAuth(
// `withAuth` augments your `Request` with the user's token.
function middleware(req) {
console.log(req.nextauth.token)
},
{
callbacks: {
authorized: ({ token }) => token?.role === "admin",
},
}
)
Note: You can modify the middleware to suit your needs.
Add the withAuth.ts file to your middleware config:
export const middlewareConfig: MiddlewareListConfig = [
[withAuth as any, "*"]
]
FAQs
This package allows you to separate your middleware into multiple files instead of having one big mono-middleware file.
We found that next-middleware-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.