Skip to content

Instantly share code, notes, and snippets.

@MarcoAlejandro
Created December 19, 2018 02:34
Show Gist options
  • Save MarcoAlejandro/d8dfd034a73825ceacc718fd7541c393 to your computer and use it in GitHub Desktop.
Save MarcoAlejandro/d8dfd034a73825ceacc718fd7541c393 to your computer and use it in GitHub Desktop.
Expressjs recipes.
//https://expressjs.com/en/guide/routing.html
//Always is better to user express.Router to modularize routing in your app.
var express = require('express')
var router = express.Router()
// middleware that is specific to this router
router.use(function timeLog (req, res, next) {
console.log('Time: ', Date.now())
next()
})
// 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