resting-squirrel-mysql-api-key
v0.5.1
Published
Api key validator for resting-squirrel using mysql database.
Downloads
12
Readme
resting-squirrel-mysql-api-key
Api key validator for resting-squirrel using mysql database.
Installation
$ npm install resting-squirrel-mysql-api-key --save
Usage
Validator
import rs from 'resting-squirrel';
import RSApiKey from 'resting-squirrel-mysql-api-key';
const rsApiKey = RSApiKey({/* DB config */});
const app = rs({
apiKey: {
enabled: true,
validator: rsApiKey,
},
});
app.start();
Creation of the api key
Javascript
import RSApiKey from 'resting-squirrel-mysql-api-key';
const rsApiKey = RSApiKey({/* DB config */});
// Creates api key for client "identificator" with 50 daily api calls limit
rsApiKey.createApiKey('identificator', 50, (err, apiKey) => {
if (err) {
console.error(err);
return;
}
console.log(apiKey);
});
Command line
# Creates api key for client "identificator" with 50 daily api calls limit
node_modules/.bin/rs-api-key-create --identificator=identificator --limit=50 --mysql-host=localhost --mysql-user=user --mysql-password=passwd --mysql-database=project_database
# Creates api key for client "identificator" with 50 daily api calls limit with mysql url connection string
node_modules/.bin/rs-api-key-create --mysql=mysql://user:passwd@localhost/project_database
TODO
CLI
- delete api key
- update api key
- reset quota