Skip to content

Instantly share code, notes, and snippets.

@adam-lynch
Created August 17, 2015 20:54
Show Gist options
  • Save adam-lynch/2c00fcbe18fcb5c4b85a to your computer and use it in GitHub Desktop.
Save adam-lynch/2c00fcbe18fcb5c4b85a to your computer and use it in GitHub Desktop.
browserSync = require 'browsersync'
# if you're using gulp, replace this with `require('gulp-util').colors`
chalk = require 'chalk'
# method - {String} (uppercase)
colourMethod = (method) ->
map =
'GET': 'green'
'POST': 'yellow'
'PUT': 'blue'
'DELETE': 'red'
if map[method]?
return chalk[map[method]] method
else
return method
browserSync
server:
baseDir: 'blah'
middleware: (req, res, next) ->
# if you're using gulp, replace `console.log` with `require('gulp-util').log`
console.log colourMethod(req.method), req.url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment