# nestjs-configure-after

> Order NestJS middlewares execution

Latest version **5.0.0** (published 2026-08-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install nestjs-configure-after
pnpm add nestjs-configure-after
yarn add nestjs-configure-after
bun add nestjs-configure-after
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-08-31 |
| First published | 2019-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.12.0 |
| Dependencies | 0 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 14 |
| Author | iamolegga |
| Maintainers | iamolegga |
| Keywords | nest, nestjs, middleware, module, configure, MiddlewareConsumer, consumer, order, after |

## Links

- npm: https://www.npmjs.com/package/nestjs-configure-after
- Repository: https://github.com/iamolegga/nestjs-configure-after
- Homepage: https://github.com/iamolegga/nestjs-configure-after#readme
- Issues: https://github.com/iamolegga/nestjs-configure-after/issues
- npm.io page: https://npm.io/package/nestjs-configure-after

## 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

- 5.0.0 (latest) — 2026-08-31
- 4.0.0-alpha.9eeffe (alpha) — 2026-08-31
- 4.0.0 — 2025-01-24
- 3.0.0-alpha.7a4512 — 2025-01-24
- 3.0.0-alpha.7152c3 — 2025-01-24
- 3.0.0-alpha.76c16b — 2025-01-24
- 3.0.0 — 2023-08-16
- 2.0.0-alpha.4c3588 — 2023-08-16
- 2.0.0-alpha.feb130 — 2023-08-14
- 2.0.0-alpha.1d506c — 2023-08-09
- 2.0.0-alpha.aac712 — 2023-08-07
- 2.0.0-alpha.2d3dcb — 2023-08-07
- 2.0.0-alpha.3a8fa8 — 2023-08-07
- 2.0.0-alpha.94f833 — 2023-08-04
- 2.0.0-alpha.3a3dda — 2023-08-04
- … 538 more at https://npm.io/package/nestjs-configure-after/versions

## README

<h1 align="center">nestjs-configure-after</h1>

<p align="center">
  <a href="https://www.npmjs.com/package/nestjs-configure-after">
    <img alt="npm" src="https://img.shields.io/npm/v/nestjs-configure-after" />
  </a>
  <a href="https://www.npmjs.com/package/nestjs-configure-after">
    <img alt="npm" src="https://img.shields.io/npm/dm/nestjs-configure-after" />
  </a>
  <a href="https://github.com/iamolegga/nestjs-configure-after/actions">
    <img alt="GitHub branch checks state" src="https://badgen.net/github/checks/iamolegga/nestjs-configure-after/master">
  </a>
  <a href="https://qlty.sh/gh/iamolegga/projects/nestjs-configure-after">
    <img src="https://qlty.sh/gh/iamolegga/projects/nestjs-configure-after/coverage.svg" alt="Code Coverage" />
  </a>
  <a href="https://snyk.io/test/github/iamolegga/nestjs-configure-after">
    <img alt="Known Vulnerabilities" src="https://snyk.io/test/github/iamolegga/nestjs-configure-after/badge.svg" />
  </a>
  <a href="https://libraries.io/npm/nestjs-configure-after">
    <img alt="Libraries.io" src="https://img.shields.io/librariesio/release/npm/nestjs-configure-after">
  </a>
  <img alt="Dependabot" src="https://badgen.net/github/dependabot/iamolegga/nestjs-configure-after">
</p>

Using NestJS?

Do you have middlewares set via `configure(consumer: MiddlewareConsumer) {}` and want to control the order of execution of these middlewares?

---

<p align="center"><b>This is the documentation for v5. Compatibility with earlier versions:</b></p>

| nestjs-configure-after | NestJS       | Node.js |
| ---------------------- | ------------ | ------- |
| v5                     | 11, 12       | >=22.12 |
| [v4](https://github.com/iamolegga/nestjs-configure-after/tree/4.0.0#readme) | 8, 9, 10, 11 | >=18 |

---

## Install

```sh
npm i nestjs-configure-after
```

## Example

Let's assume we have ModuleA, ModuleB, and ModuleC, and each has its own middleware setup. And we want these middlewares to be set in the correct order, like A -> B -> C. By default NestJS does not provide the way to set the order. But with this library it's possible:

```ts
import { After } from 'nestjs-configure-after'

@Module({})
//
// Empty if independent
//
@After()
class ModuleA {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(FirstMiddleware)
      .forRoutes('*');
  }
}

@Module({})
//
// Pass module that should configure it's middlewares
// before the current one
//
@After(ModuleA)
class ModuleB {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(SecondMiddlewareThatShouldBeExecutedAfterTheFirstOne)
      .forRoutes('*');
  }
}

@Module({})
//
// ...Or even pass several modules
//
@After(ModuleA, ModuleB)
class ModuleC {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(TheLastMiddleware)
      .forRoutes('*');
  }
}

@Module({
  // And for now it does not matter in which
  // order modules are set in `imports` field
  // Middlewares will be setup in the right order.
  imports: [ModuleC, ModuleA, ModuleB, ...],
  controllers: [...]
})
class App {}
```

<h2 align="center">Do you use this library?<br/>Don't be shy to give it a star! ★</h2>

<h3 align="center">Also if you are into NestJS you might be interested in one of my <a href="https://github.com/iamolegga#nestjs">other NestJS libs</a>.</h3>

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