diff options
author | William Harrington <kb0iic@berzerkula.org> | 2019-04-17 21:59:22 -0500 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2019-04-17 21:59:22 -0500 |
commit | e719de425d7607368d530373002d8f550747fb79 (patch) | |
tree | 6fd650012b1859030f9501af3b2ace62d659ecb6 | |
parent | fda25494564015e0fdaa7742746ca0fbb7185f80 (diff) |
Install moment and utilize it in logger to add timestamp after url.
-rw-r--r-- | index.js | 9 | ||||
-rw-r--r-- | package-lock.json | 5 | ||||
-rw-r--r-- | package.json | 5 |
3 files changed, 15 insertions, 4 deletions
@@ -1,13 +1,18 @@ const express = require('express'); const path = require('path'); 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}`); + console.log( + `${req.protocol}://${req.get('host')}${ + req.originalUrl + }: ${moment().format()}` + ); next(); -} +}; // Init middleware app.use(logger); diff --git a/package-lock.json b/package-lock.json index bdc34aa..e0ae599 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1868,6 +1868,11 @@ } } }, + "moment": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", diff --git a/package.json b/package.json index e7845ec..0977c51 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "> Files for the [YouTube crash course](https://www.youtube.com/watch?v=L72fhGm1tfE)", "main": "index.js", "scripts": { - "dev": "nodemon index" + "dev": "nodemon index" }, "repository": { "type": "git", @@ -14,7 +14,8 @@ "author": "", "license": "ISC", "dependencies": { - "express": "^4.16.4" + "express": "^4.16.4", + "moment": "^2.24.0" }, "devDependencies": { "nodemon": "^1.18.11" |