Skip to content

Instantly share code, notes, and snippets.

@suissa
Last active March 29, 2018 16:22
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 suissa/8a9f9bc292cfe825aa63e70f93d6d283 to your computer and use it in GitHub Desktop.
Save suissa/8a9f9bc292cfe825aa63e70f93d6d283 to your computer and use it in GitHub Desktop.
router
'use strict'
const methods = require('./methods')
/** */
const getMethod = (req) => req.method.toLowerCase()
const end = (res, method) => {
console.log('request incorrect: ', method)
res.end()
}
module.exports = (req, res) =>
(methods.includes(getMethod(req)))
? require(`./${ getMethod(req) }`)(req, res)
: end(res, getMethod(req))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment