lib/rateLimiter/lib/rateLimiter.js
function (key, timeInterval, limit) {
        //Validate rate limiter settings
        if (!_.isNumber(timeInterval) || parseInt(timeInterval) <= 0 || !_.isNumber(limit) || parseInt(limit) <= 0) {
            return Q.reject();
        }
        var cacheKey = Encryption.md5("MiaJSRateLimit" + key + _calculateCurrentTimeInterval(timeInterval));
        return _validateRateLimit(cacheKey, timeInterval, limit).then(function (value) {
            return Q({
                limit: limit,
                remaining: limit - value,
                timeInterval: timeInterval,
                timeTillReset: _getTimeLeftTillReset(timeInterval)
            });
        });
    }
function (key, timeInterval, limit) {
        //Validate rate limiter settings
        if (!_.isNumber(timeInterval) || parseInt(timeInterval) <= 0 || !_.isNumber(limit) || parseInt(limit) <= 0) {
            return Q.reject();
        }
        var cacheKey = Encryption.md5("MiaJSRateLimit" + key + _calculateCurrentTimeInterval(timeInterval));
        return _validateRateLimit(cacheKey, timeInterval, limit).then(function (value) {
            return Q({
                limit: limit,
                remaining: limit - value,
                timeInterval: timeInterval,
                timeTillReset: _getTimeLeftTillReset(timeInterval)
            });
        });
    }
function ( key , timeInterval , limit ) { //Validate rate limiter settings if ( ! _ . isNumber ( timeInterval ) || parseInt ( timeInterval ) <= 0 || ! _ . isNumber ( limit ) || parseInt ( limit ) <= 0 ) { return Q . reject ( ) ; } var cacheKey = Encryption . md5 ( "MiaJSRateLimit" + key + _calculateCurrentTimeInterval ( timeInterval ) ) ; return _validateRateLimit ( cacheKey , timeInterval , limit ) . then ( function ( value ) { return Q ( { limit : limit , remaining : limit - value , timeInterval : timeInterval , timeTillReset : _getTimeLeftTillReset ( timeInterval ) } ) ; } ) ; }
Check global rate limits per ip
Check global rate limits per ip