Skip to content

Instantly share code, notes, and snippets.

@addisonj
Created December 21, 2011 20:57
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 addisonj/1507669 to your computer and use it in GitHub Desktop.
Save addisonj/1507669 to your computer and use it in GitHub Desktop.
normalize a response
// with normalizing middleware
app.use(normalizeResponse)
app.get('/account', common, UserRead)
function UserRead(req, res, next) {
// do stuff and attach it onto the res object
// call next() when done
next()
}
function normalizeResponse(req, res) {
//gets called last by every resquest
// does what it needs and then
res.json(res.response)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment