anote-server-libs 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anote-server-libs",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Helpers for express-TS servers",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/services/utils.js CHANGED
@@ -99,11 +99,11 @@ function idempotent(repo, debug, logger) {
99
99
  jsonTerminator(obj);
100
100
  });
101
101
  }).bind(res);
102
- res.end = (function () {
102
+ res.end = (function (buf) {
103
103
  repo.ApiCall.create({
104
104
  id: idempotenceKey,
105
105
  responseCode: res.statusCode,
106
- responseJson: undefined,
106
+ responseJson: buf && buf.toString(),
107
107
  expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000)
108
108
  }).then(() => endTerminator(), err => {
109
109
  if (err)
@@ -116,7 +116,7 @@ function idempotent(repo, debug, logger) {
116
116
  else
117
117
  res.status(417).json({
118
118
  responseCode: call.responseCode,
119
- responseBody: JSON.parse(call.responseJson)
119
+ responseBody: call.responseJson
120
120
  });
121
121
  }, err => res.status(500).json({
122
122
  error: {