Skip to content

Instantly share code, notes, and snippets.

@justlaputa
Created June 7, 2018 23:27
Show Gist options
  • Save justlaputa/05d71ac44f91c9c407c2da3f8d35a2db to your computer and use it in GitHub Desktop.
Save justlaputa/05d71ac44f91c9c407c2da3f8d35a2db to your computer and use it in GitHub Desktop.
var app = express()
var bodyParser = require('body-parser')
// third party middleware
// parse application/json
app.use(bodyParser.json())
// user defined middleware
app.use(function (req, res, next) {
console.log('Time:', Date.now())
next()
})
// use middleware for specific url path
app.use('/user/:id', function (req, res, next) {
checkUser(req.params.id)
next()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment