robot-check-service.js 772 Bytes
'use strict';

const cache = global.yoho.cache.master;
const Promise = require('bluebird');
const co = Promise.coroutine;
const config = global.yoho.config;
const _ = require('lodash');

const HeaderModel = require('../../../doraemon/models/header');

const index = co(function* (channel) {
    const header = yield HeaderModel.requestHeaderData(channel);

    return {
        headerData: header.headerData
    };
});

const removeBlack = (remoteIp) => {
    let operations = [cache.delAsync(`${config.app}:limiter:${remoteIp}`)];

    _.forEach(config.REQUEST_LIMIT, (val, key) => {
        operations.push(cache.delAsync(`${config.app}:limiter:${key}:max:${remoteIp}`));
    });

    return Promise.all(operations);
};

module.exports = {
    index,
    removeBlack
};