mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Semicolons
This commit is contained in:
@@ -5,7 +5,7 @@ Ap.removeDefaultRateLimit = function () {
|
||||
const resp = DDPRateLimiter.removeRule(defaultRateLimiterRuleId);
|
||||
defaultRateLimiterRuleId = null;
|
||||
return resp;
|
||||
}
|
||||
};
|
||||
|
||||
// Add a default rule of limiting logins, creating new users and password reset
|
||||
// to 5 times every 10 seconds per connection.
|
||||
@@ -24,6 +24,6 @@ Ap.addDefaultRateLimit = function () {
|
||||
}
|
||||
}, 5, 10000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Ap.addDefaultRateLimit();
|
||||
Ap.addDefaultRateLimit();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Rate Limiter built into DDP with a default error message. See README or
|
||||
// online documentation for more details.
|
||||
DDPRateLimiter = {}
|
||||
DDPRateLimiter = {};
|
||||
|
||||
var errorMessage = function (rateLimitResult) {
|
||||
return "Error, too many requests. Please slow down. You must wait " +
|
||||
Math.ceil(rateLimitResult.timeToReset / 1000) + " seconds before " +
|
||||
"trying again.";
|
||||
}
|
||||
};
|
||||
var rateLimiter = new RateLimiter();
|
||||
|
||||
DDPRateLimiter.getErrorMessage = function (rateLimitResult) {
|
||||
@@ -14,7 +14,7 @@ DDPRateLimiter.getErrorMessage = function (rateLimitResult) {
|
||||
return errorMessage(rateLimitResult);
|
||||
else
|
||||
return errorMessage;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Set error message text when method or subscription rate limit
|
||||
@@ -26,7 +26,7 @@ DDPRateLimiter.getErrorMessage = function (rateLimitResult) {
|
||||
*/
|
||||
DDPRateLimiter.setErrorMessage = function (message) {
|
||||
errorMessage = message;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary
|
||||
@@ -70,7 +70,7 @@ DDPRateLimiter.addRule = function (matcher, numRequests, timeInterval) {
|
||||
|
||||
DDPRateLimiter.printRules = function () {
|
||||
return rateLimiter.rules;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Removes the specified rule from the rate limiter. If rule had
|
||||
@@ -80,14 +80,14 @@ DDPRateLimiter.printRules = function () {
|
||||
*/
|
||||
DDPRateLimiter.removeRule = function (id) {
|
||||
return rateLimiter.removeRule(id);
|
||||
}
|
||||
};
|
||||
|
||||
// This is accessed inside livedata_server.js, but shouldn't be called by any
|
||||
// user.
|
||||
DDPRateLimiter._increment = function (input) {
|
||||
rateLimiter.increment(input);
|
||||
}
|
||||
};
|
||||
|
||||
DDPRateLimiter._check = function (input) {
|
||||
return rateLimiter.check(input);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -596,7 +596,7 @@ _.extend(Session.prototype, {
|
||||
};
|
||||
|
||||
DDPRateLimiter._increment(rateLimiterInput);
|
||||
var rateLimitResult = DDPRateLimiter._check(rateLimiterInput)
|
||||
var rateLimitResult = DDPRateLimiter._check(rateLimiterInput);
|
||||
if (!rateLimitResult.allowed) {
|
||||
self.send({
|
||||
msg: 'nosub', id: msg.id,
|
||||
|
||||
@@ -112,7 +112,7 @@ RateLimiter = function () {
|
||||
// id. Each rule object stores the rule pattern, number of events allowed,
|
||||
// last reset time and the rule reset interval in milliseconds.
|
||||
self.rules = {};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if this input has exceeded any rate limits.
|
||||
@@ -172,7 +172,7 @@ RateLimiter.prototype.check = function (input) {
|
||||
}
|
||||
});
|
||||
return reply;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a rule to dictionary of rules that are checked against on every call.
|
||||
@@ -196,12 +196,12 @@ RateLimiter.prototype.addRule = function (rule, numRequestsAllowed,
|
||||
var options = {
|
||||
numRequestsAllowed: numRequestsAllowed || DEFAULT_REQUESTS_PER_INTERVAL,
|
||||
intervalTime: intervalTime || DEFAULT_INTERVAL_TIME_IN_MILLISECONDS
|
||||
}
|
||||
};
|
||||
|
||||
var newRule = new Rule(options, rule);
|
||||
this.rules[newRule.id] = newRule;
|
||||
return newRule.id;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Increment counters in every rule that match to this input
|
||||
@@ -228,7 +228,7 @@ RateLimiter.prototype.increment = function (input) {
|
||||
else
|
||||
rule.counters[ruleResult.key] = 1;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Returns an array of all rules that apply to provided input
|
||||
RateLimiter.prototype._findAllMatchingRules = function (input) {
|
||||
@@ -237,7 +237,7 @@ RateLimiter.prototype._findAllMatchingRules = function (input) {
|
||||
return _.filter(self.rules, function(rule) {
|
||||
return rule.match(input);
|
||||
});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Provides a mechanism to remove rules from the rate limiter. Returns boolean
|
||||
* about success.
|
||||
@@ -252,4 +252,4 @@ RateLimiter.prototype.removeRule = function (id) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user