1.0.6 • Published 4 years ago

@juntoz/koa-require-header v1.0.6

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

koa-require-header

This package contains a middleware that will require an http header to be present on the request, and if present, it will write the value into a state variable.

To install the package

npm install @juntoz/koa-require-header

To use it

const koaRequireHeader = require('@juntoz/koa-require-header');

var koaApp = new Koa();

koaApp.use(koaRequireHeader({ /*options*/ }));

Where options is an object that can contain the following fields

{
    headerName: null, // header name that should come in the request to validate and match
    stateName: null, // optional ctx.state property name when the header is found. If null, the headerName is converted to camelCase.
    ifNotFound: 'throw' // set what to do if the header is not found. Possible values ['throw', 'ignore'].
}
1.0.6

4 years ago

1.0.5

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago