# express-request-id

> Generate UUID for request

Latest version **3.0.0** (published 2022-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-request-id
pnpm add express-request-id
yarn add express-request-id
bun add express-request-id
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2022-10-05 |
| First published | 2014-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^14.20.1 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 123 |
| Author | Vsevolod Strukchinsky |
| Maintainers | floatdrop |
| Keywords | express, middleware, request, id, uuid |

## Links

- npm: https://www.npmjs.com/package/express-request-id
- Repository: https://github.com/floatdrop/express-request-id
- Homepage: https://github.com/floatdrop/express-request-id#readme
- Issues: https://github.com/floatdrop/express-request-id/issues
- npm.io page: https://npm.io/package/express-request-id

## Dependencies (1)

- [uuid](https://npm.io/package/uuid.md) ^9.0.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

- 3.0.0 (latest) — 2022-10-05
- 2.0.1 — 2022-01-16
- 2.0.0 — 2022-01-14
- 1.4.1 — 2018-09-27
- 1.4.0 — 2017-03-14
- 1.3.0 — 2017-02-02
- 1.2.0 — 2017-01-13
- 1.1.1 — 2016-12-26
- 1.1.0 — 2015-04-13
- 1.0.0 — 2014-07-02
- 0.0.0 — 2014-07-02

## README

# express-request-id

[![Tests](https://github.com/floatdrop/express-request-id/workflows/CI/badge.svg)](https://github.com/floatdrop/express-request-id/actions)
[![npm version](https://img.shields.io/npm/v/express-request-id.svg)](https://npmjs.org/package/express-request-id 'View this project on NPM')
[![npm downloads](https://img.shields.io/npm/dm/express-request-id)](https://www.npmjs.com/package/express-request-id)

> Generates UUID for request and add it to header.

## Install

```sh
npm install express-request-id
```

## Usage

```js
import express from 'express';
import requestID from 'express-request-id';

app.use(requestID());

app.get('/', function (req, res, next) {
    res.send(req.id);
    next();
});

app.listen(3000, function() {
    console.log('Listening on port %d', server.address().port);
});

// curl localhost:3000
// d7c32387-3feb-452b-8df1-2d8338b3ea22
```

## API

### requestID(options?)

#### options

Type: `object`

##### generator

Type: `function`
Default: `func(req) { return uuidv4(); }`

Defines function, that generated ID from request. By default used `uuid` module, that generated UUID V4 for every request. 

##### headerName

Type: `string`
Default: `X-Request-Id`

Defines name of header, that should be used for request ID checking and setting.

##### setHeader

Type: `bool`
Default: `true`

If `false` – header will not be set.

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