Skip to content

Commit

Permalink
chore(package): use lodash.pick and lodash.unset instead of lodash.omit
Browse files Browse the repository at this point in the history
  • Loading branch information
yidinghan committed Apr 10, 2017
1 parent 453f871 commit a998f15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 7 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
const winston = require('winston');
const omit = require('lodash.omit');
const unset = require('lodash.unset');
const pick = require('lodash.pick');

exports.serializer = {
req: (payload) => {
const {
headersIgnore = ['cookie'],
reqIgnores = ['headers.cookie'],
reqkeys = ['headers', 'url'],
} = payload;

return (req) => {
const headers = omit(req.headers || {}, headersIgnore);
const url = req.url;
const logObject = pick(req, reqkeys);
reqIgnores.forEach(unset.bind(unset, logObject));

return {
headers,
url,
};
return logObject;
};
},
};
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "1.2.1",
"description": "koa2 version winston logger like express-winston",
"main": "index.js",
"engines" : {
"node" : ">=7.6"
"engines": {
"node": ">=7.6"
},
"scripts": {
"lint": "eslint ./test/*.js ./index.js --fix",
"release": "standard-version",
"test": "ava"
},
Expand All @@ -31,7 +32,8 @@
"winston": "^2.3.1"
},
"dependencies": {
"lodash.omit": "^4.5.0"
"lodash.pick": "^4.4.0",
"lodash.unset": "^4.5.2"
},
"devDependencies": {
"ava": "^0.19.0",
Expand Down

0 comments on commit a998f15

Please sign in to comment.