A client for the Divvy rate limit server.
- NodeJS version 4 or newer.
const DivvyClient = require('@button/divvy-client');
const client = new DivvyClient('localhost', 8321);
client.hit({ method: 'GET', path: '/pantry/cookies' }).then((result) => {
console.log(`Success: ${JSON.stringify(result)}`);
// { allowed: true, currentCredit: 100, nextResetSeconds: 60 }
}).catch((err) => {
console.log(`Error: ${err.message}`);
});
A stub of the interface is exposed as Client.Stub
, which implements the core methods (connect, close, and hit).
Licensed under the MIT license. See LICENSE.txt
for full terms.
Copyright 2016 Button, Inc.