1.3.0 • Published 8 months ago

@vpriem/express-api-key-auth v1.3.0

Weekly downloads
7,614
License
MIT
Repository
github
Last release
8 months ago

express-api-key-auth

Tiny express middleware to authenticate x-api-key request header.

Install

yarn add @vpriem/express-api-key-auth

API

import { apiKeyAuth } from '@vpriem/express-api-key-auth';

apiKeyAuth(apiKeys: string[]): Handler

Create an express middleware with a given list of allowed api keys.
Throwing 401 for all request with header x-api-key not matching the given list.

import { apiKeyAuth } from '@vpriem/express-api-key-auth';

express().use(apiKeyAuth(['my-api-key1', 'my-api-key2']));

apiKeyAuth(regExp: RegExp): Handler

Create the auth middleware based on all env vars with the name matching the given RegExp.

import { apiKeyAuth } from '@vpriem/express-api-key-auth';

express().use(apiKeyAuth(/^API_KEY_/));

This will create a handler with a list of api keys matching all process.env.API_KEY_* env vars.

License

MIT

1.2.0

11 months ago

1.3.0

8 months ago

1.1.0

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

0.0.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago