Skip to content

Instantly share code, notes, and snippets.

@makefunstuff
Created March 4, 2017 23:32
Show Gist options
  • Save makefunstuff/b34690dcbd01044523ff345e9926042a to your computer and use it in GitHub Desktop.
Save makefunstuff/b34690dcbd01044523ff345e9926042a to your computer and use it in GitHub Desktop.
// 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