Skip to content

Commit

Permalink
Run next() after successfully sending data to the client (parse-commu…
Browse files Browse the repository at this point in the history
…nity#2338)

This allows developers to add express handlers for successful completion of parse-server requests.
ie Analytics or Logging.
  • Loading branch information
blacha authored and Rafael Santos committed Mar 16, 2017
1 parent fd26599 commit 59e4bbd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/PromiseRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,17 @@ function makeExpressHandler(appId, promiseHandler) {
res.status(status);

if (result.text) {
return res.send(result.text);
res.send(result.text);
return next();
}

if (result.location) {
res.set('Location', result.location);
// Override the default expressjs response
// as it double encodes %encoded chars in URL
if (!result.response) {
return res.send('Found. Redirecting to '+result.location);
res.send('Found. Redirecting to '+result.location);
return next();
}
}
if (result.headers) {
Expand All @@ -201,6 +203,7 @@ function makeExpressHandler(appId, promiseHandler) {
})
}
res.json(result.response);
next();
}, (e) => {
log.error(`Error generating response. ${inspect(e)}`, {error: e});
next(e);
Expand Down

0 comments on commit 59e4bbd

Please sign in to comment.