api-token
Simple module for Node.js that can be used e.g. for REST api session management.
Installation
npm install api-token --save
Usage
Node.js server
setup api-token
var apiToken = ;/* set expiration time to 2 minutes */apiToken;
expressjs
Example how to use api-token module in Express application. For more details see Example project.
appall'/api/*' { ifrequrl === '/api/authenticate' /* token is not needed when authenticating */ ; else ifapiToken /* if token is valid continue */ ; else /* if token is not valid send unauthorized http statuscode to client */ res; };
app;
plain http server
Example how to use api-token with http server.
http;
Example project
Example application which demonstrates the use of the module. https://github.com/laardee/api-token-expressjs-demo
Release History
- 0.1.0 Initial release