JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q38755F
  • License MIT

Manage quotas using Redis and NodeJS.

Package Exports

  • node-quotas

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-quotas) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-quotas Build Status

This module enables management of quotas in redis.

NPM NPM

API

var Quotas = require('quotas');

var config = {
  quotas: {
      emails: {limit: 100}, // limit of 100 emails for the given period
      sms: {limit: 100, expires: 3600} // limit of 100 sms' for the 3600 seconds (5 minutes)
  },
  redisUrl: 'redis://localhost',
  expires: 86400 // default expiry of 1 day
};

var quotas = new Quotas(config);

// initialise and check all the settings.
quotas.initialise();

quotas.check(12345, 'emails', function(err, result) {
    if(err) return cb(err)// do whatever

    // check the result is > 0 and let the operation through
    ...

});

features

  • Set default quotas given a unique user identifier, a type and a default value.

License

Copyright (c) 2014 Mark Wolfe released under the MIT license.