index.js
602 Bytes
const compose = require('koa-compose');
const _ = require('lodash');
const qpsPath = require('./qps-path');
const qps = require('./qps');
const APP_NAME = {
'yohobuy-node': 'pc',
'yohobuywap-node': 'wap',
UNKNOWN: ''
};
module.exports = () => {
const handlers = compose([qpsPath, qps]);
return async(m) => {
const user = {
uid: _.get(m, 'fields.uid', ''),
ip: _.get(m, 'fields.ip', ''),
app: APP_NAME[_.get(m, 'tags.app', 'UNKNOWN')],
path: _.get(m, 'fields.path', '')
};
await handlers({user});
};
};