From e719de425d7607368d530373002d8f550747fb79 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Wed, 17 Apr 2019 21:59:22 -0500 Subject: Install moment and utilize it in logger to add timestamp after url. --- index.js | 9 +++++++-- package-lock.json | 5 +++++ package.json | 5 +++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 07d9a16..4721f34 100644 --- a/index.js +++ b/index.js @@ -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" -- cgit v1.2.3-54-g00ecf