Blame view

doraemon/middleware/req-params-filter.js 537 Bytes
徐炜 authored
1 2 3 4 5
const _ = require('lodash');

// 黑名单参数
const BLACK_LIST = [
    'client_secret',
郭成尧 authored
6 7
    'method',
    'openby:yohobuy'
徐炜 authored
8 9 10 11 12 13
];

module.exports = () => {
    return (req, res, next) => {
        if (req.query) {
            _.forEach(BLACK_LIST, (key) => {
陈轩 authored
14 15 16 17
                if (key === 'client_secret') {
                    req.yoho.client_secret = req.query[key];
                }
徐炜 authored
18 19 20 21 22 23 24 25 26
                if (req.query[key]) {
                    delete req.query[key];
                }
            });
        }

        next();
    };
};