# inflight-requests

> inflight requests counter middleware for express/connect

Latest version **0.1.0** (published 2018-12-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-12-05 |
| First published | 2018-12-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.4.0 |
| Dependencies | 1 |
| Unpacked size | 105.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Guilherme Hermeto |
| Maintainers | ghermeto |
| Keywords | inflight, inflight-requests, express, restify, fastify, connect, middleware, in-flight |

## Links

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

## Dependencies (1)

- [events-decorator](https://npm.io/package/events-decorator.md) ^0.2.0

## 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.1.0 (latest) — 2018-12-05

## README

# Inflight Requests

[![node](https://img.shields.io/node/v/inflight-requests.svg)]()
[![Build Status](https://travis-ci.org/ghermeto/inflight-requests.svg?branch=master)](https://travis-ci.org/ghermeto/inflight-requests)
[![npm](https://img.shields.io/npm/v/inflight-requests.svg)](https://www.npmjs.com/package/inflight-requests)
[![GitHub](https://img.shields.io/github/license/ghermeto/inflight-requests.svg)](https://github.com/ghermeto/inflight-requests/blob/master/LICENSE)
[![David](https://img.shields.io/david/ghermeto/inflight-requests.svg)](https://david-dm.org/ghermeto/inflight-requests)
[![David](https://img.shields.io/david/dev/ghermeto/inflight-requests.svg)](https://david-dm.org/ghermeto/inflight-requests?type=dev)

In-flight requests counter middleware for express (and other servers with similar middleware signature).

## Install

```sh
$ npm install --save inflight-requests
```

## API

```javascript
const inflightRequests = require('inflight-requests');
```

### inflightRequests([context])

Will count the number of in-flight requests. If the optional`context` argument is provided, 
it will be mutated to add an `inflightRequests` counter property. 

```javascript
const inflightRequests = require('inflight-requests');
const app = express();

app.use(inflightRequests());
```
   
#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| context | `Object`  | defaults to `{ inflightRequests: 0 }`  |

#### Returns

`function(req, res, next): void` express/connect style middleware function 

### middleware.requestsCount()

returns the number of
```javascript
const inflightRequests = require('inflight-requests');
const inflight = inflightRequests();

assert(inflight.requestsCount() === 0);
```
#### Returns

`number` the number of in-flight requests   

## Examples

Using the default counter and checking the current requests count:

```javascript
const inflightRequests = require('inflight-requests');
const inflight = inflightRequests();
const app = express();

app.use(inflight);
assert(inflight.requestsCount() === 0);
```

Passing a context to record the `inflightRequests` property:

```javascript
const app = express();
const inflightRequests = require('inflight-requests');

app.use(inflightRequests(app.locals));
assert(app.locals.inflightRequests === 0);
```
---

MIT © [Guilherme Hermeto](http://github.com/ghermeto)

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