Skip to content

Instantly share code, notes, and snippets.

@mguida22
Created January 28, 2020 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mguida22/3a6a9cd9a401ff007660b35a618c66f9 to your computer and use it in GitHub Desktop.
Save mguida22/3a6a9cd9a401ff007660b35a618c66f9 to your computer and use it in GitHub Desktop.
const express = require('express')
const app = express()
const port = 3000
const logger = (req, res, next) => {
const timestamp = new Date()
console.log(`${timestamp} A request was made to: ${req.path}`)
next()
}
app.use(logger)
app.get('/hello', (req, res) => {
res.status(200).send('Hello World.')
})
app.listen(port, () => {
console.log(`express server listening on port ${port}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment