mware is a lightweight utility designed to create and manage sequential middleware stacks, inspired by patterns found in frameworks like Connect. It provides a simple API (`use` and `run`) to define a series of functions that process a shared context and can either proceed to the next middleware, halt the stack with a success signal, or terminate it by reporting an error. The current stable version is 1.0.1. However, the project's copyright date of 2016 and the nature of its last fix suggest it is largely unmaintained. Its key differentiator is its minimalism, offering a core middleware pattern without the overhead or specific request/response abstractions typical of larger web frameworks, making it suitable for generic processing pipelines in both Node.js and browser environments.
npm install mwareVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize `mware`, add multiple asynchronous middleware functions, and run the stack with a context. It shows how middleware can modify the context, stop the stack early with a result, or terminate with an error.
Evaluate for alternatives if long-term maintenance, security, or feature development is a concern, or consider forking for internal maintenance.
Always pass errors to the `next` function (e.g., `return next(new Error('...'))`) to ensure they are properly caught by the `done` callback.You must first call the `mware` function to get an instance. Correct: `const { use, run } = mware();`Ensure your middleware function correctly accepts `(ctx, next)` as arguments, or however you've chosen to name your context and next callback.
Every middleware function must eventually call `next()` (or `return next(null, result)`/`return next(error)`) to ensure control flow proceeds or terminates correctly.
No dependency data recorded yet.