https://github.com/celeri-server/middleware-pipeline
A generic library for creating middleware pipelines
https://github.com/celeri-server/middleware-pipeline
celeri middleware nodejs
Last synced: about 1 month ago
JSON representation
A generic library for creating middleware pipelines
- Host: GitHub
- URL: https://github.com/celeri-server/middleware-pipeline
- Owner: celeri-server
- License: isc
- Created: 2017-05-01T03:45:33.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-01-06T08:02:06.000Z (over 5 years ago)
- Last Synced: 2025-03-11T07:05:19.253Z (over 1 year ago)
- Topics: celeri, middleware, nodejs
- Language: TypeScript
- Homepage: https://www.celerijs.com/docs/middleware-pipeline.html
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
```bash
$ npm install --save @celeri/middleware-pipeline
```
### Import
#### ES6 Modules
```javascript
import { MiddlewarePipeline } from '@celeri/middleware-pipeline';
```
#### CommonJS Modules
```javascript
const { MiddlewarePipeline } = require('@celeri/middleware-pipeline');
```
### Usage
```javascript
const pipieline = new MiddlewarePipeline();
pipeline
// Middlewares can be async functions to be awaited
.use(async (url) => await httpGet(url))
// Or they can be normal functions
.use((body) => JSON.parse(body))
// Error handling middleware can be placed with catch
.catch({ error } => console.error(error))
// A catch implies that the error was handled (unless it also throws),
// so following middleware will still run
.use(() => {
// This runs regardless of whether the first two steps passed
});
pipeline.run('http://www.example.com');
```