Created
December 7, 2016 20:00
-
-
Save sleexyz/ce477b98c832c03fd76f100026f7b4b5 to your computer and use it in GitHub Desktop.
higher order middleware
This file contains hidden or 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
const parseReqAndThen = (reqParser, onSuccess) => { | |
return (req, res, next) => { | |
const parseResult = reqParser(req); | |
if (typeof parseResult !== 'undefined') { | |
const successApp = connect() | |
.use(onSuccess(parseResult)) | |
.use((req, res) => {next();}); | |
successApp(req, res); | |
return; | |
} | |
next(); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment