Package Exports
- middleware-io
- middleware-io/lib/index
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (middleware-io) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Modern middleware on Promise
| 📖 Documentation |
|---|
Features
- Working with async/await
- Zero dependencies
- Native Promise
- Flexible
- Snippets
- Typings
Installation
Node.js 10.0.0 or newer is required
Yarn
Recommended
yarn add middleware-ioNPM
npm install middleware-io --saveUsage
import { compose } from 'middleware-io';
const composedMiddleware = compose([
async (context, next) => {
// Step 1
await next();
// Step 4
// Print the current date from the next middleware
console.log(context.now);
},
async (context, next) => {
// Step 2
context.now = Date.now();
await next();
// Step 3
}
]);
composedMiddleware({}, context => { /* Last middleware */ })
.then(() => {
console.log('Middleware finished work');
})
.catch(console.error);