From f58c176ab51cdf8a9564e27a09f2488b2daf44a3 Mon Sep 17 00:00:00 2001 From: Blayne Chard Date: Wed, 20 Jul 2016 14:20:07 +1200 Subject: [PATCH] Run next() after successfully sending data to the client This allows developers to add express handlers for successful completion of parse-server requests. ie Analytics or Logging. --- src/PromiseRouter.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/PromiseRouter.js b/src/PromiseRouter.js index 2c90039393..1252b22747 100644 --- a/src/PromiseRouter.js +++ b/src/PromiseRouter.js @@ -184,7 +184,8 @@ function makeExpressHandler(appId, promiseHandler) { res.status(status); if (result.text) { - return res.send(result.text); + res.send(result.text); + return next(); } if (result.location) { @@ -192,7 +193,8 @@ function makeExpressHandler(appId, promiseHandler) { // 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) { @@ -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);