Registry / web-framework / composable-middleware

composable-middleware

JSON →
library0.3.1jsnpmunverified

Composable Middleware allows developers to treat a sequence of Connect, Flatiron/Union, or hybrid middleware functions as a single, unified middleware function. The package, currently at version 0.3.1, is explicitly marked as abandoned and no longer actively maintained. Its core differentiation lies in its minimal overhead design, focusing solely on function composition without built-in support for URL routing, path mounting, or comprehensive error handling (like 404/500 responses), which are left to the parent framework. It identifies middleware types based on function arity (e.g., `(req,res,next)` for Connect normal middleware, `(err,req,res,next)` for error handling). Given its abandoned status, there is no active release cadence, and users are encouraged to consider maintained forks or alternative solutions.

npm install composable-middleware
INSTALL
IMPORT
SIG · COMPOSABLE-MIDDLEW
C
composable-middleware
web-frameworkjavascriptv0.3.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.

composable_middleware
const composable_middleware = require('composable-middleware');
import composable_middleware from 'composable-middleware';
This package is CommonJS-only. Direct ESM imports will fail. You may need a CJS interop layer for modern ESM projects.
composable_middleware().use
const mw = require('composable-middleware')().use(logger);
import { use } from 'composable-middleware';
The `use` method is a member of the object returned by the main export, not a named export itself. It's chained after invoking the default export.

Demonstrates how to compose multiple middleware functions into a single unit using `composable-middleware` and integrate it into a `connect` application. It includes basic logging and a response.

const connect = require('connect'); const composable_middleware = require('composable-middleware'); // Mock connect middleware for demonstration const logger = (req, res, next) => { console.log(`${req.method} ${req.url}`); next(); }; const greet = (req, res, next) => { res.setHeader('Content-Type', 'text/plain'); res.end('Hello from composed middleware!\n'); next(); // Even though we end, pass to next for completion or logging }; const finalHandler = (req, res) => { if (!res.headersSent) { res.statusCode = 404; res.end('Not Found\n'); } }; // Compose middleware steps const composedMw = composable_middleware(logger, greet); // Create a Connect app and use the composed middleware const app = connect(); app.use(composedMw); app.use(finalHandler); const PORT = process.env.PORT ?? 3000; app.listen(PORT, () => { console.log(`Server running on http://localhost:${PORT}`); console.log('Try accessing http://localhost:3000/'); });
Debug
Known issues
breakingThis package is explicitly marked as 'Abandoned' by its maintainers. It is no longer actively developed or supported, which means no new features, bug fixes, or security patches will be released. Using it in production carries significant risk.
fix
Migrate to a maintained fork (e.g., `ineentho/composable-middleware`) or an alternative middleware composition library. Assess the risks of continued use.
affects: >=0.3.1
gotchaThe package is CommonJS-only and does not support native ES Modules (ESM) `import` statements directly. Attempting to use `import` without a CJS interop layer will result in errors.
fix
Use CommonJS `require()` syntax: `const composable_middleware = require('composable-middleware');`. For ESM projects, consider dynamic `import()` or a build step to transpile.
affects: >=0.3.1
gotchaComposable Middleware intentionally does not handle routing, path mounting, or default error responses (like 404 Not Found or 500 Internal Server Error). Developers must provide their own 'finalware' or rely on the overarching framework for these concerns.
fix
Implement explicit routing middleware (e.g., `express.Router()`) before or after your composed middleware, and ensure a final middleware handles 404/500 errors if the request reaches the end of the stack without a response.
affects: >=0.3.1
gotchaThe package targets Node.js versions `>=0.8.0`. While it might run on newer Node.js versions, it has not been tested or updated for modern Node.js APIs or performance optimizations. Compatibility issues or subtle bugs may arise.
fix
Thoroughly test on your target Node.js version. Be aware that certain Node.js APIs might have changed behavior or been deprecated since the package's last update.
affects: >=0.3.1
Errors
Common errors & fixes
TypeError: composable_middleware is not a function
Attempting to use `composable_middleware` as a function when it was imported incorrectly, likely as a named export in an ESM context, or without a `require` call.
fix
Ensure you are using `const composable_middleware = require('composable-middleware');` for CommonJS projects or if dynamically importing in ESM.
ERR_REQUIRE_ESM
You are attempting to `require()` an ESM module, or more likely, you are in an ESM context and attempting to `import` this CJS-only package directly without interop.
fix
If in an ESM module, you must use dynamic import `const composable_middleware = await import('composable-middleware');` or refactor your project to use CommonJS where this package is needed. The `composable-middleware` package itself is CommonJS.
Cannot read properties of undefined (reading 'use')
This error often occurs if `composable_middleware` itself is `undefined` because `require('composable-middleware')` failed, or if you tried `composable_middleware.use()` directly without first invoking `composable_middleware()` to get an instance.
fix
Verify the package is installed and `require()` is correct. Ensure you invoke the main export to get an instance before calling `.use()`: `const mw = composable_middleware().use(someMiddleware);`
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
4
Perplexity
1
OpenAI (training)
1
Resources
composable-middleware — npm install composable-middleware · libregistry