Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const eventBus = DI.get('eventBus');
const userService = DI.get('userService');
const contestService = DI.get('contestService');
const submissionService = DI.get('submissionService');
const systemPropertyService = DI.get('systemPropertyService');
const logger = DI.get('logger');
// cache scoreboard
let scoreboardCache = null;
eventBus.on('contest.challenge.visibilityChanged', () => scoreboardCache = null);
eventBus.on('contest.current.changed', () => scoreboardCache = null);
eventBus.on('contest.submission.passed', () => scoreboardCache = null);
eventBus.on('contest.registrant.new', () => scoreboardCache = null);
const registrantLimiter = promisify(RateLimiter({
redis: DI.get('redis'),
namespace: 'limiter-flag-user',
interval: 5 * 60 * 1000,
maxInInterval: 10,
}));
async function enforceCurrentContestExists(req, res, next) {
const contestId = await systemPropertyService.get('current_contest', '');
if (!contestId) {
next(new UserError(i18n.__('error.contest.notfound')));
return;
}
req.contestId = contestId;
next();
}