check.js
713 Bytes
'use strict';
const cache = global.yoho.cache.master;
exports.index = (req, res) => {
res.render('check', {
width750: true,
localCss: true
});
};
exports.submit = (req, res) => {
let remoteIp = req.get('X-Forwarded-For') || req.ip;
if (remoteIp.indexOf(',') > 0) {
let arr = remoteIp.split(',');
remoteIp = arr[0];
}
let key = `pc:limiter:${remoteIp}`;
let key10m = `pc:limiter:10m:${remoteIp}`;
Promise.all([
cache.delAsync(key),
cache.delAsync(key10m)
]).then(() => {
return res.json({
code: 200
});
}).catch(() => {
return res.json({
code: 400
});
});
};