😘 Middle Ware Async, easily create your own middleware layer. It's like koa's middleware.
$ npm install mwa
# or yarn
$ yarn add mwaconst app = mwa()
app.use(async (state, next) => {
console.log('mw1 start: ', state)
state.a = 1
await next()
console.log('mw1 end: ', state)
})
app.use(async (state, next) => {
console.log('mw2 start: ', state)
state.b = 1
await next()
console.log('mw2 end: ', state)
})
;(async () => {
const initialState = {}
await app.run(initialState)
console.log('all completed')
})()Return a new Mwa instance.
Use the given middleware. Return the instance itself.
- Type:
async functionorasync function[] - Details: middleware function.
Run all middlewares. Return a Promise.
- Type:
any - Details: middleware context.
- Fork it on GitHub!
- Clone the fork to your own machine.
- Checkout your feature branch:
git checkout -b my-awesome-feature - Commit your changes to your own branch:
git commit -am 'Add some feature' - Push your work back up to your fork:
git push -u origin my-awesome-feature - Submit a Pull Request so that we can review your changes.
NOTE: Be sure to merge the latest from "upstream" before making a pull request!