# @osskit/enforce-client-headers

> Enforce headers against http calls to your API

Latest version **0.0.9** (published 2022-06-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @osskit/enforce-client-headers
pnpm add @osskit/enforce-client-headers
yarn add @osskit/enforce-client-headers
bun add @osskit/enforce-client-headers
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2022-06-20 |
| First published | 2021-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | osskit |

## Links

- npm: https://www.npmjs.com/package/@osskit/enforce-client-headers
- Repository: https://github.com/osskit/enforce-client-headers
- Homepage: https://github.com/osskit/enforce-client-headers#readme
- Issues: https://github.com/osskit/enforce-client-headers/issues
- npm.io page: https://npm.io/package/@osskit/enforce-client-headers

## Dependencies (1)

- [http-errors](https://npm.io/package/http-errors.md) ^2.0.0

## Recent versions

- 0.0.9 (latest) — 2022-06-20
- 0.0.8 — 2022-06-19
- 0.0.7 — 2022-06-18
- 0.0.6 — 2022-02-22
- 0.0.5 — 2021-08-24
- 0.0.4 — 2021-08-24
- 0.0.3 — 2021-07-28
- 0.0.2 — 2021-07-18

## README

# enforce-client-headers
Enforce headers against http calls to your API

## Install
```
yarn add @osskit/enforce-client-headers
```

## Usages

### Simple
```
import { enforceClientHeaders } from '@osskit/enforce-client-headers'

const server = express();
const socketServer = io();

server.use(enforceClientHeaders());
socketServer.use(enforceClientHeaders());
```

### Extra headers

```
import { enforceClientHeaders, requiredHeaders } from '@osskit/enforce-client-headers'

const server = express();
const socketServer = io();

const headers = [...requiredHeaders, 'my-extra-header'];

server.use(enforceClientHeaders({headers});
socketServer.use(enforceClientHeaders, {headers});
```

## API

### enforceClientHeaders({headers})
#### headers
Type: `string[]`

The headers you want to enforce on the request

Throws a `400 - missing ${header}` error upon missing required header

### requiredHeaders

Type: `string[]`, by default `['x-api-client', 'x-api-client-version']`

---
_Source: https://npm.io/package/@osskit/enforce-client-headers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
