@rill/set

1.1.0 • Public • Published

Rill
@rill/set
API stability Standard NPM version Downloads Gitter Chat

Simple utility to set a local variable using a middleware.

Installation

npm install @rill/set

Example

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 }
	}
})

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!

Package Sidebar

Install

npm i @rill/set

Weekly Downloads

32

Version

1.1.0

License

MIT

Last publish

Collaborators

  • dylanpiercey