Skip to content

Instantly share code, notes, and snippets.

@bouchtaoui-dev
Created January 16, 2019 10:56
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 bouchtaoui-dev/e80f4a273de28365c839da63e4a4922e to your computer and use it in GitHub Desktop.
Save bouchtaoui-dev/e80f4a273de28365c839da63e4a4922e to your computer and use it in GitHub Desktop.
var express = require('express')
var router = express.Router()
// middleware that is specific to this router
// this will be called for every request (get, put, update and delete)
router.use(function timeLog (req, res, next) {
console.log('Time: ', Date.now())
next() // pass control to the nex router int he chain
})
// define the home page route
router.get('/', function (req, res) {
res.send('Birds home page')
})
// define the about route
router.get('/about', function (req, res) {
res.send('About birds')
})
module.exports = router
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment