Use express logger compatible with nginx
This commit is contained in:
parent
28eec3e28c
commit
c35760d95e
4 changed files with 50 additions and 107 deletions
129
package-lock.json
generated
129
package-lock.json
generated
|
@ -77,6 +77,15 @@
|
||||||
"integrity": "sha512-v/lko8AvmTt1K8p+ebdhdiHJE7zpPBYsDKjJSNCl8GwPGkKe5xND7s6M36LKye/USbWSPA7gYCDL0+DZ5h0L6Q==",
|
"integrity": "sha512-v/lko8AvmTt1K8p+ebdhdiHJE7zpPBYsDKjJSNCl8GwPGkKe5xND7s6M36LKye/USbWSPA7gYCDL0+DZ5h0L6Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/morgan": {
|
||||||
|
"version": "1.7.35",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/morgan/-/morgan-1.7.35.tgz",
|
||||||
|
"integrity": "sha512-E9qFi0seOkdlQnCTPv54brNfGWeFdRaEhI5tSue4pdx/V+xfxvMETsxXhOEcj1cYL+0n/jcTEmj/jD2gjzCwMg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/express": "4.11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "9.4.0",
|
"version": "9.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.4.0.tgz",
|
||||||
|
@ -122,11 +131,6 @@
|
||||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"ansi-styles": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-yxAt8cVvUSPquLZ817mAJ6AnkXg="
|
|
||||||
},
|
|
||||||
"array-flatten": {
|
"array-flatten": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||||
|
@ -144,11 +148,6 @@
|
||||||
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
|
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"async": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k="
|
|
||||||
},
|
|
||||||
"async-cache": {
|
"async-cache": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/async-cache/-/async-cache-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/async-cache/-/async-cache-1.1.0.tgz",
|
||||||
|
@ -275,16 +274,6 @@
|
||||||
"check-error": "1.0.2"
|
"check-error": "1.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chalk": {
|
|
||||||
"version": "0.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz",
|
|
||||||
"integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=",
|
|
||||||
"requires": {
|
|
||||||
"ansi-styles": "1.0.0",
|
|
||||||
"has-color": "0.1.7",
|
|
||||||
"strip-ansi": "0.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"check-error": {
|
"check-error": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
|
||||||
|
@ -306,11 +295,6 @@
|
||||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
|
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"colors": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
|
|
||||||
"integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs="
|
|
||||||
},
|
|
||||||
"combined-stream": {
|
"combined-stream": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz",
|
||||||
|
@ -456,11 +440,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||||
},
|
},
|
||||||
"cycle": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz",
|
|
||||||
"integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI="
|
|
||||||
},
|
|
||||||
"dasherize": {
|
"dasherize": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/dasherize/-/dasherize-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/dasherize/-/dasherize-2.0.0.tgz",
|
||||||
|
@ -688,26 +667,12 @@
|
||||||
"ipaddr.js": "1.4.0"
|
"ipaddr.js": "1.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"express-winston": {
|
|
||||||
"version": "2.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/express-winston/-/express-winston-2.4.0.tgz",
|
|
||||||
"integrity": "sha1-J6ts2TBT4t/cNbzuoUoHfcfVLkk=",
|
|
||||||
"requires": {
|
|
||||||
"chalk": "0.4.0",
|
|
||||||
"lodash": "4.11.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extend": {
|
"extend": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
|
||||||
"integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=",
|
"integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"eyes": {
|
|
||||||
"version": "0.1.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz",
|
|
||||||
"integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
|
|
||||||
},
|
|
||||||
"fast-safe-stringify": {
|
"fast-safe-stringify": {
|
||||||
"version": "1.2.3",
|
"version": "1.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-1.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-1.2.3.tgz",
|
||||||
|
@ -821,11 +786,6 @@
|
||||||
"ansi-regex": "2.1.1"
|
"ansi-regex": "2.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"has-color": {
|
|
||||||
"version": "0.1.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz",
|
|
||||||
"integrity": "sha1-ZxRKUmDDT8PMpnfQQdr1L+e3iy8="
|
|
||||||
},
|
|
||||||
"has-flag": {
|
"has-flag": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz",
|
||||||
|
@ -988,11 +948,6 @@
|
||||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
|
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"isstream": {
|
|
||||||
"version": "0.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
|
|
||||||
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
|
|
||||||
},
|
|
||||||
"js-tokens": {
|
"js-tokens": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
|
||||||
|
@ -1015,11 +970,6 @@
|
||||||
"source-map": "0.5.7"
|
"source-map": "0.5.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lodash": {
|
|
||||||
"version": "4.11.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.11.2.tgz",
|
|
||||||
"integrity": "sha1-1rQzixEKWOIdrlzrz9u/0rxM2zs="
|
|
||||||
},
|
|
||||||
"lodash._baseassign": {
|
"lodash._baseassign": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
|
||||||
|
@ -1206,6 +1156,41 @@
|
||||||
"resolved": "https://registry.npmjs.org/module-details-from-path/-/module-details-from-path-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/module-details-from-path/-/module-details-from-path-1.0.3.tgz",
|
||||||
"integrity": "sha1-EUyUlnPiqKNenTV4hSeqN7Z52is="
|
"integrity": "sha1-EUyUlnPiqKNenTV4hSeqN7Z52is="
|
||||||
},
|
},
|
||||||
|
"morgan": {
|
||||||
|
"version": "1.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz",
|
||||||
|
"integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=",
|
||||||
|
"requires": {
|
||||||
|
"basic-auth": "2.0.0",
|
||||||
|
"debug": "2.6.9",
|
||||||
|
"depd": "1.1.2",
|
||||||
|
"on-finished": "2.3.0",
|
||||||
|
"on-headers": "1.0.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"basic-auth": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=",
|
||||||
|
"requires": {
|
||||||
|
"safe-buffer": "5.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"version": "2.6.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||||
|
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"ms": {
|
"ms": {
|
||||||
"version": "0.7.1",
|
"version": "0.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
|
||||||
|
@ -1441,8 +1426,7 @@
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
||||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
|
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "5.5.0",
|
"version": "5.5.0",
|
||||||
|
@ -1598,11 +1582,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/sql-summary/-/sql-summary-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/sql-summary/-/sql-summary-1.0.0.tgz",
|
||||||
"integrity": "sha1-OeOlHY2F5Gc5g2/H1n0GVLFzo58="
|
"integrity": "sha1-OeOlHY2F5Gc5g2/H1n0GVLFzo58="
|
||||||
},
|
},
|
||||||
"stack-trace": {
|
|
||||||
"version": "0.0.10",
|
|
||||||
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
|
|
||||||
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
|
|
||||||
},
|
|
||||||
"stackman": {
|
"stackman": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/stackman/-/stackman-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/stackman/-/stackman-2.0.1.tgz",
|
||||||
|
@ -1630,11 +1609,6 @@
|
||||||
"safe-buffer": "5.1.1"
|
"safe-buffer": "5.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"strip-ansi": {
|
|
||||||
"version": "0.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz",
|
|
||||||
"integrity": "sha1-OeipjQRNFQZgq+SmgIrPcLt7yZE="
|
|
||||||
},
|
|
||||||
"strip-bom": {
|
"strip-bom": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
|
||||||
|
@ -1908,19 +1882,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||||
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
||||||
},
|
},
|
||||||
"winston": {
|
|
||||||
"version": "2.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/winston/-/winston-2.3.1.tgz",
|
|
||||||
"integrity": "sha1-C0hCDZeMAYBM8CMLZIhhWYIloRk=",
|
|
||||||
"requires": {
|
|
||||||
"async": "1.0.0",
|
|
||||||
"colors": "1.0.3",
|
|
||||||
"cycle": "1.0.3",
|
|
||||||
"eyes": "0.1.8",
|
|
||||||
"isstream": "0.1.2",
|
|
||||||
"stack-trace": "0.0.10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
|
|
|
@ -33,12 +33,11 @@
|
||||||
"express": "4.15.3",
|
"express": "4.15.3",
|
||||||
"express-basic-auth": "1.0.1",
|
"express-basic-auth": "1.0.1",
|
||||||
"express-ip-access-control": "1.0.5",
|
"express-ip-access-control": "1.0.5",
|
||||||
"express-winston": "2.4.0",
|
|
||||||
"helmet": "3.6.1",
|
"helmet": "3.6.1",
|
||||||
|
"morgan": "1.9.0",
|
||||||
"opbeat": "4.14.0",
|
"opbeat": "4.14.0",
|
||||||
"open": "0.0.5",
|
"open": "0.0.5",
|
||||||
"serve-index": "1.9.0",
|
"serve-index": "1.9.0"
|
||||||
"winston": "2.3.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chai": "4.1.2",
|
"@types/chai": "4.1.2",
|
||||||
|
@ -46,6 +45,7 @@
|
||||||
"@types/express": "4.11.0",
|
"@types/express": "4.11.0",
|
||||||
"@types/helmet": "0.0.37",
|
"@types/helmet": "0.0.37",
|
||||||
"@types/mocha": "2.2.47",
|
"@types/mocha": "2.2.47",
|
||||||
|
"@types/morgan": "1.7.35",
|
||||||
"@types/serve-index": "1.7.29",
|
"@types/serve-index": "1.7.29",
|
||||||
"chai": "4.0.2",
|
"chai": "4.0.2",
|
||||||
"chai-as-promised": "7.1.1",
|
"chai-as-promised": "7.1.1",
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
import * as expressWinston from 'express-winston';
|
|
||||||
import * as winston from 'winston';
|
|
||||||
|
|
||||||
export default expressWinston.logger({
|
|
||||||
colorize: true,
|
|
||||||
meta: false,
|
|
||||||
msg: '{{ req.url }} '
|
|
||||||
.concat('status:{{ res.statusCode }} ')
|
|
||||||
.concat('useragent:{{ req.headers["user-agent"] }} ')
|
|
||||||
.concat('time:{{ res.responseTime }}ms'),
|
|
||||||
statusLevels: true,
|
|
||||||
transports: [
|
|
||||||
new winston.transports.Console({
|
|
||||||
colorize: true
|
|
||||||
})
|
|
||||||
],
|
|
||||||
});
|
|
|
@ -6,9 +6,8 @@ import * as helmet from 'helmet';
|
||||||
import * as opbeat from 'opbeat';
|
import * as opbeat from 'opbeat';
|
||||||
import * as expectCt from 'expect-ct';
|
import * as expectCt from 'expect-ct';
|
||||||
import * as referrerPolicy from 'referrer-policy';
|
import * as referrerPolicy from 'referrer-policy';
|
||||||
|
import * as morgan from 'morgan';
|
||||||
|
|
||||||
|
|
||||||
import logging from './middleware/logging';
|
|
||||||
import basicAuthHandler from './middleware/basic-auth';
|
import basicAuthHandler from './middleware/basic-auth';
|
||||||
import { serveIndexHandle, indexHandle, staticFileHandle } from './middleware/static-files';
|
import { serveIndexHandle, indexHandle, staticFileHandle } from './middleware/static-files';
|
||||||
import handle404 from './middleware/404';
|
import handle404 from './middleware/404';
|
||||||
|
@ -36,7 +35,7 @@ export default function createServer(opts : Options) : express.Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
app.use(logging);
|
app.use(morgan('combined'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.allowed_ips.length) {
|
if (opts.allowed_ips.length) {
|
||||||
|
|
Reference in a new issue