Skip to content

Commit

Permalink
feat: use morgan for logging in expressjs server
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Feb 20, 2020
1 parent 162eb1a commit ea4c800
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
30 changes: 28 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"express": "^4.17.1",
"express-robots-txt": "0.4.1",
"lodash-es": "^4.17.15",
"morgan": "^1.9.1",
"ng-recaptcha": "^5.0.0",
"ng2-validation": "^4.2.0",
"ngx-infinite-scroll": "^8.0.1",
Expand Down
8 changes: 8 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ app.engine(
app.set('view engine', 'html');
app.set('views', join(DIST_FOLDER, 'browser'));

if (logging) {
app.use(
require('morgan')('tiny', {
skip: req => req.originalUrl.startsWith('/INTERSHOP/static'),
})
);
}

// seo robots.txt
const pathToRobotsTxt = join(DIST_FOLDER, 'robots.txt');
if (fs.existsSync(pathToRobotsTxt)) {
Expand Down

0 comments on commit ea4c800

Please sign in to comment.