# node-inflight-requests

> Measure the number of inflight requests in your Node.js server.

Latest version **1.0.1** (published 2019-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-inflight-requests
pnpm add node-inflight-requests
yarn add node-inflight-requests
bun add node-inflight-requests
```

## 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.1 |
| Published | 2019-06-19 |
| First published | 2019-06-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Vignesh Shanmugam |
| Maintainers | vignesh.shanmugam |
| Keywords | inflight, request, congestion |

## Links

- npm: https://www.npmjs.com/package/node-inflight-requests
- Repository: https://github.com/vigneshshanmugam/node-inflight-requests
- Homepage: https://github.com/vigneshshanmugam/node-inflight-requests#readme
- Issues: https://github.com/vigneshshanmugam/node-inflight-requests/issues
- npm.io page: https://npm.io/package/node-inflight-requests

## Dependencies (1)

- [end-of-stream](https://npm.io/package/end-of-stream.md) ^1.4.1

## Recent versions

- 1.0.1 (latest) — 2019-06-19
- 1.0.0 — 2019-06-19

## README

# node-inflight-requests

Measure the number of inflight requests at any single time in your Node.js server.

### Install

```
npm install node-inflight-requests
```

### Usage

```js
const http = require("http");
const congestion = require("node-inflight-requests")();
const server = http.createServer(serve);

function serve(req, res) {
  const inflightReqs = congestion(res);

  console.log("No of requests in flight", inflightReqs);

  reportMetrics(inflightReqs);

  if (inflightReqs > 100) {
    res.statusCode = 503; // Service Unavailable
    res.setHeader("Retry-After", 10);
  }

  res.end();
}
```

### License

The MIT License (MIT)

Copyright (c) 2019 [Vignesh Shanmugam](https://vigneshh.in)

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