express response-time
const express = require('express');
const bodyParser = require('body-parser');
const responseTime = require('response-time')
const app = express();
// use JSON
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// add ResponseTime Funtion
app.use(responseTime((req, res, time) => {
// log the responseTime with URL and method
console.log(`${req.method} ${req.url} ${time}`);
}))
app.get('/', (req, res) => {
res.send('foo');
});
app.listen(3000);
// Logs something like: GET / 0.9935419999999997