New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

volos-quota-common

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

volos-quota-common - npm Package Compare versions

Comparing version 0.9.7 to 0.9.8

21

lib/memory_buffer.js

@@ -29,2 +29,3 @@ /****************************************************************************

var _ = require('underscore');
var debug = require('debug')('apigee');

@@ -83,3 +84,3 @@ /*

bucket.flushBucket(function(err, reply) { // sync count (and possibly time) with remote
bucket.flushBucket(function(err) { // sync count (and possibly time) with remote
if (err) { return cb(err); }

@@ -120,3 +121,3 @@ bucket.apply(now, options, cb);

Bucket.prototype.reset = function(time) {
if (debugEnabled) { debug('bucket reset'); }
if (debug.enabled) { debug('bucket reset'); }
this.count = 0;

@@ -158,2 +159,3 @@ this.resetAt = time;

var count = this.count + this.remoteCount;
if (!this.expiryTime) { this.calculateExpiration(); }
var result = {

@@ -195,3 +197,3 @@ allowed: allow,

self.owner.clockOffset = offset;
if (debugEnabled) { debug('clockOffset: ' + offset); }
if (debug.enabled) { debug('clockOffset: ' + offset); }
}

@@ -201,3 +203,3 @@

(!remoteExpires || remoteExpires === self.remoteExpires); // same remote time bucket?
if (debugEnabled && !sameTimeBucket) { debug('new time bucket'); }
if (debug.enabled && !sameTimeBucket) { debug('new time bucket'); }
if (!sameTimeBucket) { return cb ? cb() : null; }

@@ -215,12 +217,1 @@

};
var debug;
var debugEnabled;
if (process.env.NODE_DEBUG && /apigee/.test(process.env.NODE_DEBUG)) {
debug = function(x) {
console.log('Apigee: ' + x);
};
debugEnabled = true;
} else {
debug = function() { };
}

@@ -27,2 +27,3 @@ /****************************************************************************

var _ = require('underscore');
var debug = require('debug')('quota');

@@ -75,3 +76,3 @@ function QuotaArgo(quota, options) {

function applyQuota(self, options, response, next) {
if (debugEnabled) { debug('Quota check: ' + options.identifier); }
if (debug.enabled) { debug('Quota check: ' + options.identifier); }
self.quota.apply(

@@ -81,3 +82,3 @@ options,

if (err) {
if (debugEnabled) { debug('Quota apply error: ' + err); }
if (debug.enabled) { debug('Quota apply error: ' + err); }
response.statusCode = 500;

@@ -91,3 +92,3 @@ response.body = { error: 'error applying quota' };

if (!reply.isAllowed) {
if (debugEnabled) { debug('Quota exceeded: ' + options.identifier); }
if (debug.enabled) { debug('Quota exceeded: ' + options.identifier); }
response.statusCode = 403;

@@ -100,13 +101,1 @@ response.body = { error: 'exceeded quota' };

}
var debugEnabled;
var debug;
if (process.env.NODE_DEBUG && /quota/.test(process.env.NODE_DEBUG)) {
debug = function(x) {
console.log('Quota: ' + x);
};
debugEnabled = true;
} else {
debug = function() { };
}

@@ -27,2 +27,3 @@ /****************************************************************************

var _ = require('underscore');
var debug = require('debug')('quota');

@@ -64,3 +65,3 @@ function QuotaConnect(quota, options) {

opts.identifier = opts.identifier + '/' + remoteAddress;
if (debugEnabled) { debug('Quota check: ' + opts.identifier); }
if (debug.enabled) { debug('Quota check: ' + opts.identifier); }
applyQuota(self, opts, resp, next);

@@ -79,3 +80,3 @@ };

function applyQuota(self, options, resp, next) {
if (debugEnabled) { debug('Quota check: ' + options.identifier); }
if (debug.enabled) { debug('Quota check: ' + options.identifier); }
self.quota.apply(

@@ -89,3 +90,3 @@ options,

if (!reply.isAllowed) {
if (debugEnabled) { debug('Quota exceeded: ' + options.identifier); }
if (debug.enabled) { debug('Quota exceeded: ' + options.identifier); }
resp.statusCode = 403;

@@ -98,13 +99,1 @@ return resp.end(JSON.stringify({ error: 'exceeded quota' }));

}
var debug;
var debugEnabled;
if (process.env.NODE_DEBUG && /quota/.test(process.env.NODE_DEBUG)) {
debug = function(x) {
console.log('Quota: ' + x);
};
debugEnabled = true;
} else {
debug = function() { };
}

@@ -119,10 +119,14 @@ /****************************************************************************

var options = o || {};
options.weight = checkNumber(o.weight, 'weight') || 1;
options.allow = checkNumber(o.allow, 'allow') || this.options.allow;
try {
options.weight = checkNumber(o.weight, 'weight') || 1;
options.allow = checkNumber(o.allow, 'allow') || this.options.allow;
} catch (err) {
return cb(err);
}
if (!options.identifier) {
throw new Error('identifier must be set');
return cb(new Error('identifier must be set'));
}
if (typeof options.identifier !== 'string') {
throw new Error('identifier must be a string');
return cb(new Error('identifier must be a string'));
}

@@ -129,0 +133,0 @@

{
"name": "volos-quota-common",
"version": "0.9.7",
"version": "0.9.8",
"main": "lib/quota.js",

@@ -13,2 +13,3 @@ "license": "MIT",

"dependencies": {
"debug": "1.0.x",
"underscore": "1.6.x"

@@ -15,0 +16,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc