Registry / web-framework / mware
library1.0.1jsnpmunverified

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 mware
INSTALL
IMPORT
SIG · MWARE
M
mware
web-frameworkjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mware
import mware from 'mware';
import { mware } from 'mware';
The primary export is a default function that returns an mware instance.
mware instance methods
const { use, run } = mware();
import { use, run } from 'mware';
use and run are methods of the instance returned by calling the default mware export, not direct named exports.
mware (CommonJS)
const mware = require('mware');
const { mware } = require('mware');
For CommonJS environments, the module exports a default function directly.

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.

import mware from 'mware'; const { use, run } = mware(); // Add middleware functions use((ctx, next) => { console.log('Middleware 1: Processing context', ctx); // Modify context or perform async operations setTimeout(() => next(), 100); }); use((ctx, next) => { console.log('Middleware 2: Further processing', ctx); if (ctx.shouldStop) { console.log('Middleware 2: Stopping stack early.'); return next(null, 'Stopped Early'); // Stop the stack with a result } return next(); // Proceed to the next middleware }); use((ctx, next) => { console.log('Middleware 3: This might not run if stopped early.'); // Simulate an error condition if (ctx.fail) { return next(new Error('Simulated error in middleware 3')); // Stop and report error } next(); }); // Run the stack with an initial context const context = { value: 42, shouldStop: false, fail: false }; run([context], (err, result) => { if (err) { console.error('Stack completed with error:', err.message); } else { console.log('Stack completed successfully. Result:', result || 'No explicit result'); } console.log('Final context state:', context); });
Debug
Known issues
gotchaThe `mware` project appears to be unmaintained. The latest copyright date in the README is 2016, and version 1.0.1 primarily includes a bug fix, indicating a lack of recent active development or new features. Users should be aware there might not be future updates or security patches.
fix
Evaluate for alternatives if long-term maintenance, security, or feature development is a concern, or consider forking for internal maintenance.
affects: >=1.0.0
gotchaError handling in `mware` middleware functions is done by calling `next(new Error())` rather than `throw new Error()`. Throwing an error within a middleware function will bypass the `done` callback and might lead to unhandled promise rejections or uncaught exceptions, depending on the surrounding execution environment.
fix
Always pass errors to the `next` function (e.g., `return next(new Error('...'))`) to ensure they are properly caught by the `done` callback.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'use')
Attempting to call `.use()` or `.run()` directly on the `mware` import instead of an `mware` instance.
fix
You must first call the `mware` function to get an instance. Correct: `const { use, run } = mware();`
Error: next is not a function
Middleware function arguments are incorrectly destructured or not provided, leading to `next` being undefined.
fix
Ensure your middleware function correctly accepts `(ctx, next)` as arguments, or however you've chosen to name your context and next callback.
Middleware stack stopped unexpectedly / Stack never completes
A middleware function failed to call `next()` (or `return next()`), causing the stack to hang or stop without reporting completion to the `done` callback.
fix
Every middleware function must eventually call `next()` (or `return next(null, result)`/`return next(error)`) to ensure control flow proceeds or terminates correctly.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
mware — npm install mware · libregistry