# fastify-reqid

> Fastify Request ID Plugin

Latest version **1.0.1** (published 2022-06-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install fastify-reqid
pnpm add fastify-reqid
yarn add fastify-reqid
bun add fastify-reqid
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-06-29 |
| First published | 2022-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Black-Hole |
| Maintainers | black_hole |
| Keywords | fastify, headers, request-id, fastify-plugin |

## Links

- npm: https://www.npmjs.com/package/fastify-reqid
- Repository: https://github.com/BlackHole1/fastify-reqid
- Homepage: https://github.com/BlackHole1/fastify-reqid#readme
- Issues: https://github.com/BlackHole1/fastify-reqid/issues
- npm.io page: https://npm.io/package/fastify-reqid

## Dependencies (2)

- [nanoid](https://npm.io/package/nanoid.md) ^3.0.0
- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^3.0.1

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

- 1.0.1 (latest) — 2022-06-29
- 1.0.0 — 2022-06-29

## README

# fastify-reqid

![CI](https://github.com/BlackHole1/fastify-reqid/workflows/CI/badge.svg)
[![NPM version](https://img.shields.io/npm/v/fastify-reqid.svg?style=flat)](https://www.npmjs.com/package/fastify-reqid)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
[![NPM size](https://img.shields.io/bundlephobia/min/fastify-reqid)](https://www.npmjs.com/package/fastify-reqid)
[![Coverage Status](https://coveralls.io/repos/github/BlackHole1/fastify-reqid/badge.svg?branch=main)](https://coveralls.io/github/BlackHole1/fastify-reqid?branch=main)

> **Warning**  
> Move to: [fastify-userland/request-id](https://github.com/fastify-userland/request-id)

A plugin for Fastify that adds support for `request-id`.

Supports Fastify versions 4.x.

> Support TypeScript

## Install

```shell
# npm
npm i fastify-reqid

# pnpm
pnpm add fastify-reqid

# yarn
yarn add fastify-reqid
```

## Usage

```JavaScript
const fastify = require('fastify')()

fastify.register(require('fastify-reqid'), {
  // put your options here
})

fastify.get('/', (req, reply) => {
  reply.send({ hello: 'world' })
})

fastify.listen(3000)
```

You can use it as is without passing any option or you can configure it as explained below.

### Options

* `generateHash`: Generate x-request-id hash. For example:

```javascript
generateHash: () => {
  return uuidv4();
}
```

* `findRequestHeader`: Find request id in header. If found, the hash in the request header is used first.

* `addResponseHeader`: Add request id to header. If it is undefined, it will not be added.

## License

Licensed under [MIT](./LICENSE).

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