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
x.js
:
module.exports = x
function x(ctx, options) {
return options.condition ? transform : null
function transform(req, res, next) {
res.x = 'hello'
next()
}
}
y.js
:
module.exports = y
function y(ctx, options) {
return options.condition ? transform : null
function transform(req, res, next) {
res.y = 'world'
next()
}
}
index.js
:
var ware = require('attach-ware')(require('ware'))
var x = require('./x')
var y = require('./y')
var middleware = ware()
.use(x, {condition: true})
.use(y, {condition: false})
middleware.run({}, {}, done)
function done(err, req, res) {
if (err) throw err
console.log(res.x) // => "hello"
console.log(res.y) // => undefined
}
AttachWare = attachWare(Ware)
Create a new AttachWare
based on the given middleware constructor.
Ware
(Ware
)Function
.
AttachWare()
Create configurable middleware. Works just like the given
Ware
.
AttachWare#use(attacher[, input...])
attachWare.use(attacher[, input...])
attachWare.use(attachers[, input...])
attachWare.use(list)
attachWare.use(matrix)
attacher
(Function
) — One attacherattachers
(Array.<Function>
)
— List where each value is an attacher
list
(Array
)
— List where the first value is an attacher
, and further values
are input
matrix
(Array
)
— Matrix where each entry is a list
Invokes attacher
with context
and all input
.
If attacher
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.
AttachWare#context
The first argument for attach
ers. When this is falsey, the instance
itself is used.
FAQs
Deprecated
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.