nf-token

1.0.3 • Public • Published

nf-token

NilFactor Token is a simple package to allow you to add an api token to your restify or express server.

//...
var token = require('nf-token');
server.pre(token.verifyRequest);
//...

Create a config directory in your project with a json file called development.json or <NODE_ENV>.json whatever your NODE_ENV=thisname with the following

{
    "nfToken": {
        "apiKey": "key",
        "apiToken": "token1"
    }
}

Then when you make requests to your api create a header key/pair value of "key: token1" (req.headers.key = "token1"), if using the above example.

To allow routes that do not require a token simply doe

token.addIgnoreRoute('/');
token.addIgnoreROute('/hello/*');

Readme

Keywords

Package Sidebar

Install

npm i nf-token

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

8.21 kB

Total Files

5

Last publish

Collaborators

  • nilfactor