Registry / web-framework / meddleware

meddleware

JSON →
library3.0.4jsnpmunverified

Configuration-based middleware registration for Express.js. Current stable version is 3.0.4. Meddleware allows you to define middleware in a configuration object with options like enabled, priority, route, and module. It supports loading middleware from npm modules or local files, specifying factory methods and arguments, and flow control (parallel, series). Key differentiators include priority-based ordering, route-based activation, and parallel/sequential execution control. The package has been around since Express 4.x and is part of the Kraken.js ecosystem. It is maintained with a focus on production usage.

npm install meddleware
INSTALL
IMPORT
SIG · MEDDLEWARE
M
meddleware
web-frameworkjavascriptv3.0.4
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.

meddleware
const meddleware = require('meddleware'); const express = require('express'); const app = express(); app.use(meddleware(config));
import meddleware from 'meddleware';
meddleware is a CommonJS module; dynamic import is not typical. Use require() for now.
default export
const meddleware = require('meddleware'); app.use(meddleware(config));
const { meddleware } = require('meddleware');
The package exports a single function, not a named export.
TypeScript type import
import meddleware from 'meddleware'; app.use(meddleware(config));
const meddleware = require('meddleware');
If using TypeScript with esModuleInterop, you can use default import. Otherwise use require().

Shows basic usage of meddleware to register middleware from configuration with priority, enabled flag, and module arguments.

const http = require('http'); const express = require('express'); const meddleware = require('meddleware'); const config = { static: { enabled: true, priority: 20, module: { name: 'serve-static', arguments: ['public'] } }, security: { enabled: true, priority: 10, module: { name: './lib/security', arguments: [{ maximum: true }] } } }; const app = express(); app.use(meddleware(config)); http.createServer(app).listen(8080);
Debug
Known issues
breakingIn meddleware 2.0.0, the default value for the `enabled` option changed from `false` to `true`. Previously, omitting `enabled` would disable the middleware; now it enables it.
fix
Explicitly set `enabled: false` for middleware you want disabled, or upgrade to v3 which keeps the same behavior.
affects: >=2.0.0 <3.0.0
breakingIn meddleware 3.0.1, registered middleware factories are now called with a context set to the method owner. Previously, the factory was called with a context of `null`.
fix
Check if your middleware factory relies on `this` being `null`; if so, update it to handle the new context.
affects: >=3.0.1
deprecatedThe `priority` option is still used but may be deprecated in future versions in favor of explicit ordering.
fix
Consider using an ordered array of middleware definitions if you need strict ordering.
affects: >=3.0.0
gotchaWhen configuring meddleware with JSON files, regex patterns in routes cannot be represented natively. You must use a shortstop handler (e.g., shortstop-regex) to convert strings to RegExp.
fix
Use a JSON preprocessor like shortstop with shortstop-regex, or define config in JavaScript instead of JSON.
affects: >=2.1.0
gotchaString paths in `route` are automatically prefixed with any mountpath, but regular expressions are not. This can lead to unexpected behavior when using meddleware under a sub-app.
fix
If using regex routes, consider the mountpath manually or use string routes.
affects: >=2.1.0
gotchaThe `module.method` option defaults to the current middleware name, and then to the module itself. If your module exports a specific function, you may need to set `method` explicitly.
fix
Set `method` in the config to the exact exported function name you want to use.
affects: >=1.0.0
gotchaMeddleware uses `require.resolve()` to find the module. If the module is not in the application's node_modules, it may fail. In v3.0.4, resolution was improved for modules outside the app's node_module.
fix
Upgrade to v3.0.4 or ensure all middleware modules are in the app's node_modules directory.
affects: <3.0.4
Errors
Common errors & fixes
TypeError: meddleware is not a function
Importing the module incorrectly, e.g., using default import without esModuleInterop or named destructuring.
fix
Use `const meddleware = require('meddleware');` or enable esModuleInterop in TypeScript and use `import meddleware from 'meddleware';`
Error: Cannot find module 'some-middleware'
The module specified in config 'some-middleware' is not installed or not in the module search path.
fix
Install the module with `npm install some-middleware` and ensure it is in the app's node_modules. For local modules, use a relative path like './lib/some-middleware'.
TypeError: middlewareFactory is not a function
The module exported does not have a function matching the `method` name, or the module itself is not a function.
fix
Check the module's exports. Set `method` to the exact exported function name, or omit it if the module itself is the middleware factory.
Upgrade
Version history
3.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
meddleware — npm install meddleware · libregistry