# @macchiatojs/middleware

> The modern expressify middleware composition.

Latest version **0.2.0** (published 2021-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @macchiatojs/middleware
pnpm add @macchiatojs/middleware
yarn add @macchiatojs/middleware
bun add @macchiatojs/middleware
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2021-09-07 |
| First published | 2021-06-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 14 |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | imed jaberi |
| Maintainers | 3imed-jaberi |
| Keywords | middleware, expressify, compose, iterator |

## Links

- npm: https://www.npmjs.com/package/@macchiatojs/middleware
- Repository: https://github.com/macchiatojs/middleware
- Homepage: https://github.com/macchiatojs/middleware#readme
- Issues: https://github.com/macchiatojs/middleware/issues
- npm.io page: https://npm.io/package/@macchiatojs/middleware

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2021-09-07
- 0.1.0 — 2021-06-23

## README

# @macchiatojs/middleware

The modern **Express-Style** middleware composition.

## `Installation`

```bash
# npm
$ npm install @macchiatojs/middleware
# yarn
$ yarn add @macchiatojs/middleware
```

## `Usage`

```typescript
import Middleware from "@macchiatojs/middleware";

const middleware = new Middleware();

middleware.push((req, res, next) => {
  req.arr.push(1);
  return next().then(() => {
    req.arr.push(6);
  });
});

middleware.push(async (req, res, next) => {
  req.arr.push(2);
  await next();
  req.arr.push(5);
});

middleware.push((req, res, next) => {
  req.arr.push(3);
  next();
  req.arr.push(4);
});

const req = { arr: [] };
const res = {};
await middleware.compose(req, res);
console.log(req.arr.toString() === "1,2,3,4,5,6");
// true
```

## `Support`

If you have any problem or suggestion please open an issue.

#### License

---

[MIT](LICENSE) &copy; [Imed Jaberi](https://github.com/3imed-jaberi)

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