Created
March 4, 2017 23:32
-
-
Save makefunstuff/b34690dcbd01044523ff345e9926042a to your computer and use it in GitHub Desktop.
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
// tracker middleware | |
app.use((req, res, next) => { | |
if (req.metadata.event) { | |
tracking(req.metadata.event); | |
next(); | |
} | |
}); | |
// logger middleware | |
app.use('/data', (req, res, next) => { | |
if (req.metadata.info) { | |
logger(req.metadata.info); | |
next(); | |
} | |
}); | |
// responder middleware | |
app.use((req, res, next) => { | |
if (req.result) { | |
res.json(req.result); | |
} else { | |
next(new Error('Result not found')); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment