
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
nextjs-middleware-wrappers
Advanced tools
For the common use case of wrapping a NextJS endpoint with methods that act as middleware.
For the common use case of wrapping a NextJS endpoint with methods that act as middleware.
yarn install nextjs-middleware-wrappers
Wraps a function in layers of other functions, while preserving the input/output type. The output of wrappers will always have the type of its last parameter (the wrapped function)
This function turns this type of composition...
withDatabase(
logger.withContext("somecontext")(async (req, res) => {
res.status(200).end("...")
})
)
Into...
wrappers(
withDatabase,
logger.withContext("somecontext"),
async (req, res) => {
res.status(200).end("...")
}
)
Having this as a utility method helps preserve types, which otherwise can get messed up by the middlewares. It also can make the code cleaner where there are multiple wrappers.
In the context of request middleware you might write something like this...
const withRequestLoggingMiddleware = (next) => async (req, res) => {
console.log(`GOT REQUEST ${req.method} ${req.path}`)
return next(req, res)
}
Here's an example of a wrapper that takes some parameters...
const withLoggedArguments =
(logPrefix: string) =>
(next) =>
async (...funcArgs) => {
console.log(logPrefix, ...funcArgs)
return next(...funcArgs)
}
To have your PR be automatically deployed to NPM, make sure to tag your commit messages with the Angular JS commit message format.
i.e.
Commit message | Release type |
---|---|
fix(pencil): stop graphite breaking when too much pressure applied | Fix Release |
feat(pencil): add 'graphiteWidth' option | Feature Release |
perf(pencil): remove graphiteWidth option | |
BREAKING CHANGE: The graphiteWidth option has been removed. The default graphite width of 10mm is always used for performance reasons. | Breaking Release (Note that the BREAKING CHANGE: token must be in the footer of the commit) |
FAQs
For the common use case of wrapping a NextJS endpoint with methods that act as middleware.
The npm package nextjs-middleware-wrappers receives a total of 4,008 weekly downloads. As such, nextjs-middleware-wrappers popularity was classified as popular.
We found that nextjs-middleware-wrappers 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.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.