Last active
March 29, 2018 16:22
-
-
Save suissa/8a9f9bc292cfe825aa63e70f93d6d283 to your computer and use it in GitHub Desktop.
router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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