ti2 1.0.51 → 1.0.53
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/index.js +4 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const cacheSettings = {
|
|
|
25
25
|
};
|
|
26
26
|
const ti2Events = new EventEmitter({ captureRejections: true, wildcard: true });
|
|
27
27
|
ti2Events.on('event error', console.error);
|
|
28
|
+
ti2Events.on('error', console.error);
|
|
28
29
|
|
|
29
30
|
const schema = yaml.load(fs.readFileSync(`${__dirname}/api.yml`));
|
|
30
31
|
|
|
@@ -176,7 +177,8 @@ module.exports = async ({
|
|
|
176
177
|
10,
|
|
177
178
|
);
|
|
178
179
|
ti2Events.emit('request.end', {
|
|
179
|
-
...
|
|
180
|
+
...body,
|
|
181
|
+
cacheKey: req.cacheKey,
|
|
180
182
|
responseTimeInMs,
|
|
181
183
|
responseStatusCode: res.statusCode,
|
|
182
184
|
});
|
|
@@ -194,14 +196,13 @@ module.exports = async ({
|
|
|
194
196
|
const body = req.customBody;
|
|
195
197
|
if (cachingOperations.indexOf(body.operationId) > -1) {
|
|
196
198
|
const cacheKey = hash(R.omit(['requestId', 'date'], body));
|
|
197
|
-
|
|
199
|
+
req.cacheKey = cacheKey;
|
|
198
200
|
const foundCache = await cache.get({
|
|
199
201
|
pluginName: body.params.appKey,
|
|
200
202
|
key: cacheKey,
|
|
201
203
|
});
|
|
202
204
|
if (foundCache) {
|
|
203
205
|
// console.log('foundCache', cacheKey);
|
|
204
|
-
req.customBody.usedCache = cacheKey;
|
|
205
206
|
res.json(foundCache);
|
|
206
207
|
}
|
|
207
208
|
const realSend = res.json;
|