Hi! My name is Christian, an Agile Software Developer, living in Trento (IT).
I am currently working at XPeppers.
Read more about me.

How to use morgan with node-simple-router

,
by

Share on Twitter

You can use it like a middleware as it is supposed to be used in combination with router.any to log any reqeust of the web server.

Here a simple example:

var http = require('http')
  , router = require('node-simple-router')()
  , morgan = require('morgan')
  , logger = morgan('combined')

router.any(function(){
  logger.apply(this,arguments)
})

router.get('/hook',function(req, res) {
  res.end('incoming hook')
})


http
.createServer(router)
.listen(3000)