ti2 1.0.54 → 1.0.56

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.
@@ -11,7 +11,7 @@ const {
11
11
  },
12
12
  } = process;
13
13
 
14
- const invalid = (res, msg) => res.status(401).json({ error: msg || 'Unauthorized' });
14
+ const invalid = (res, msg) => res.status(401).send({ error: msg || 'Unauthorized' });
15
15
 
16
16
  const getToken = ({ req }) => {
17
17
  if (
package/index.js CHANGED
@@ -15,7 +15,6 @@ const EventEmitter = require('eventemitter2');
15
15
 
16
16
  const cacheSettings = {
17
17
  '*': [
18
- 'tokenTemplate',
19
18
  'getAffiliateAgents',
20
19
  'getAffiliateDesks',
21
20
  'getPickupPoints',
@@ -209,12 +208,14 @@ module.exports = async ({
209
208
  }
210
209
  const realSend = res.json;
211
210
  res.json = newData => { // new res.json
212
- cache.save({
213
- pluginName: req.pathParams.appKey,
214
- key: cacheKey,
215
- value: newData,
216
- ttl: 60 * 60 * 24, // one day
217
- });
211
+ if (res.statusCode === 200) {
212
+ cache.save({
213
+ pluginName: req.pathParams.appKey,
214
+ key: cacheKey,
215
+ value: newData,
216
+ ttl: 60 * 60 * 24, // one day
217
+ });
218
+ }
218
219
  // console.log('newData', cacheKey);
219
220
  if (!res.headersSent) {
220
221
  // console.log('send new data', cacheKey);
@@ -237,12 +238,11 @@ module.exports = async ({
237
238
  if (process.env.CONSOLE_ERRORS || process.env.JEST_WORKER_ID) {
238
239
  console.error(R.path(['response', 'data'], err), err);
239
240
  }
240
- console.log('hit hre');
241
241
  return res.status((() => {
242
242
  if (!isNumber(err.status)) return 500;
243
243
  return Number(err.status);
244
244
  })()).send({
245
- message: R.path(['response', 'data', 'errorMessage'], err) || err.message || 'Internal Error',
245
+ message: typeof err === 'string' ? err : (R.path(['response', 'data', 'errorMessage'], err) || err.message || 'Internal Error'),
246
246
  });
247
247
  });
248
248
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {