Set a local variable in all requests for Rill.
npm install @rill/setSimple utility to set a local variable using a middleware.
``console`
npm install @rill/set
`js
const app = require('rill')()
// Set a local variable for each request.
// Uses the same setter as the query string parser
app.use(set("a", 1))
app.use(set("b[]", 1))
app.use(set("c[d]", 1))
app.use(({ locals })=> {
locals //-> {
a: 1,
b: [1],
c: { d: 1 }
}
})
`
---
* Use npm test` to run tests.
Please feel free to create a PR!