# pipeline-es6

> A pipeline package written in es6 inspired by laravel pipeline

Latest version **1.0.0** (published 2019-06-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install pipeline-es6
pnpm add pipeline-es6
yarn add pipeline-es6
bun add pipeline-es6
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-06-26 |
| First published | 2019-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | xiaoxiao |
| Maintainers | xx19941215 |
| Keywords | pipeline |

## Links

- npm: https://www.npmjs.com/package/pipeline-es6
- Repository: https://github.com/xx19941215/pipeline-es6
- Homepage: https://github.com/xx19941215/pipeline-es6#readme
- Issues: https://github.com/xx19941215/pipeline-es6/issues
- npm.io page: https://npm.io/package/pipeline-es6

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-06-26

## README

pipeline-es6
============
使用E6S编写的一个类似laravel的pipeline模块.

## 安装

  ```shell
  $ npm install pipeline-es6
  ```

## 基本用法
```javascript
import {
    Pipeline
} from './node_modules/pipeline-es6/pipeline.js';


class VerifyCsrfToken {
    handle(req, next) {
        console.log("验证Csrf-Token");
        if (req == 'csrf') {
            console.log('请求非法');
        } else {
            next(req);
        }
    }
}

class ShareErrorsFromSession {
    handle(req, next) {
        console.log("如果session中有'errors'变量，则共享它");
        next(req);
    }
}

class StartSession {
    handle(req, next) {
        console.log("开启session,获取数据");
        next(req);
        console.log("保存数据，关闭session");
    }
}

class AddQueuedCookiesToResponse {
    handle(req, next) {
        next(req);
        console.log("添加下一次请求需要的cookie");
    }
}

class EncryptCookies {
    handle(req, next) {
        console.log("对输入请求的cookie进行解密");
        next(req);
        console.log("对输出响应的cookie进行加密");
    }
}

class ChecKForMaintenanceMode {
    handle(req, next) {
        console.log("确定当前程序是否处于维护状态");
        next(req);
    }
}

let pipes = {
    'VerifyCsrfToken': (req, stack) => {
        return (new VerifyCsrfToken).handle(req, stack)
    },
    'ShareErrorsFromSession': (req, stack) => {
        return (new ShareErrorsFromSession).handle(req, stack)
    },
    'StartSession': (req, stack) => {
        return (new StartSession).handle(req, stack)
    },
    'AddQueuedCookiesToResponse': (req, stack) => {
        return (new AddQueuedCookiesToResponse).handle(req, stack)
    },
    'EncryptCookies': (req, stack) => {
        return (new EncryptCookies).handle(req, stack)
    },
    'ChecKForMaintenanceMode': (req, stack) => {
        return (new ChecKForMaintenanceMode).handle(req, stack)
    },
}


let req = '请求';

let firstSlice = () => {
    console.log("请求向路由器传递，返回响应")
}

(new Pipeline(req, pipes)).then(firstSlice);
```


# License

MIT

---
_Source: https://npm.io/package/pipeline-es6 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
