mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
17 lines
556 B
CoffeeScript
17 lines
556 B
CoffeeScript
CooldownManager = require('./CooldownManager')
|
|
logger = require('logger-sharelatex')
|
|
|
|
|
|
module.exports = CooldownMiddlewear =
|
|
|
|
freezeProject: (req, res, next) ->
|
|
projectId = req.params.Project_id
|
|
if !projectId?
|
|
return next(new Error('[Cooldown] No projectId parameter on route'))
|
|
CooldownManager.isProjectOnCooldown projectId, (err, projectIsOnCooldown) ->
|
|
if err?
|
|
return next(err)
|
|
if projectIsOnCooldown
|
|
logger.log {projectId}, "[Cooldown] project is on cooldown, denying request"
|
|
return res.sendStatus(429)
|
|
next()
|