diff options
author | William Harrington <kb0iic@berzerkula.org> | 2019-04-17 22:05:03 -0500 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2019-04-17 22:05:03 -0500 |
commit | be62cdbbb12e064cc14e8d6bd8d732cd183a05c3 (patch) | |
tree | 9540ef1f3e766e8ef9152b90a51ab3680d3f4980 | |
parent | b6eeec9203a1a2c76e8eebf8fc9ea6406f63afcd (diff) |
Export logger and require moment in logger. Require middleware/logger in index.
-rw-r--r-- | index.js | 11 | ||||
-rw-r--r-- | middleware/logger.js | 12 |
2 files changed, 13 insertions, 10 deletions
@@ -1,19 +1,10 @@ const express = require('express'); const path = require('path'); +const logger = require('./middleware/logger.js'); const members = require('./Members.js'); -const moment = require('moment'); const app = express(); -const logger = (req, res, next) => { - console.log( - `${req.protocol}://${req.get('host')}${ - req.originalUrl - }: ${moment().format()}` - ); - next(); -}; - // Init middleware app.use(logger); diff --git a/middleware/logger.js b/middleware/logger.js index e69de29..bc7012e 100644 --- a/middleware/logger.js +++ b/middleware/logger.js @@ -0,0 +1,12 @@ +const moment = require('moment'); + +const logger = (req, res, next) => { + console.log( + `${req.protocol}://${req.get('host')}${ + req.originalUrl + }: ${moment().format()}` + ); + next(); +}; + +module.exports = logger; |