mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 11:54:12 -05:00
13 lines
No EOL
515 B
CoffeeScript
13 lines
No EOL
515 B
CoffeeScript
settings = require("settings-sharelatex")
|
|
redis = require('redis')
|
|
rclient = redis.createClient(settings.redis.web.port, settings.redis.web.host)
|
|
rclient.auth(settings.redis.web.password)
|
|
redback = require("redback").use(rclient)
|
|
|
|
module.exports =
|
|
|
|
addCount: (opts, callback = (opts, shouldProcess)->)->
|
|
ratelimit = redback.createRateLimit(opts.endpointName)
|
|
ratelimit.addCount opts.subjectName, opts.timeInterval, (err, callCount)->
|
|
shouldProcess = callCount < opts.throttle
|
|
callback(err, shouldProcess) |