Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
attach-ware
Advanced tools
Middleware with configuration.
npm:
npm install attach-ware
attach-ware is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.
x.js
:
module.exports = function (ctx, options) {
if (!options.condition) return;
return function (req, res, next) {
res.x = 'hello';
next();
};
}
y.js
:
module.exports = function (ctx, options) {
if (!options.condition) return;
return function (req, res, next) {
res.y = 'world';
next();
};
}
index.js
:
var ware = require('attach-ware')(require('ware'));
var x = require('./x.js');
var y = require('./y.js');
var middleware = attachWare()
.use(x, {'condition': true})
.use(y, {'condition': false})
.run({}, {}, function (err, req, res) {
console.log(res.x); // "hello"
console.log(res.y); // undefined
});
Note: first create a new constructor (later called
AttachWare
) by passingware
to the by this module exposed function. This enables ware-like libraries to be used too.
Create configurable middleware. Works just like ware()
.
Invokes attach
with either attachWare.context
or attachWare
,
and all input
.
If attach
returns another function (fn
, which can be synchronous,
asynchronous, or a generator function), that function is added to the
middleware, and will be invoked when
run()
is invoked
like normal middleware.
The first argument for attach
ers. When this is falsey, attachWare
itself is used.
FAQs
Deprecated
The npm package attach-ware receives a total of 3,021 weekly downloads. As such, attach-ware popularity was classified as popular.
We found that attach-ware 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
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.