ti2 1.0.52 → 1.0.54
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 +5 -3
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const express = require('express');
|
|
2
|
+
const compression = require('compression');
|
|
2
3
|
const createMiddleware = require('swagger-express-middleware');
|
|
3
4
|
const { connector } = require('swagger-routes-express');
|
|
4
5
|
const swaggerUi = require('swagger-ui-express');
|
|
@@ -140,6 +141,7 @@ module.exports = async ({
|
|
|
140
141
|
middleware.parseRequest(),
|
|
141
142
|
// middleware.validateRequest(),
|
|
142
143
|
);
|
|
144
|
+
app.use(compression());
|
|
143
145
|
const connect = connector(api, allSchema, {
|
|
144
146
|
security: auth,
|
|
145
147
|
notFound: (req, res) => res.sendStatus(404),
|
|
@@ -177,7 +179,8 @@ module.exports = async ({
|
|
|
177
179
|
10,
|
|
178
180
|
);
|
|
179
181
|
ti2Events.emit('request.end', {
|
|
180
|
-
...
|
|
182
|
+
...body,
|
|
183
|
+
cacheKey: req.cacheKey,
|
|
181
184
|
responseTimeInMs,
|
|
182
185
|
responseStatusCode: res.statusCode,
|
|
183
186
|
});
|
|
@@ -195,14 +198,13 @@ module.exports = async ({
|
|
|
195
198
|
const body = req.customBody;
|
|
196
199
|
if (cachingOperations.indexOf(body.operationId) > -1) {
|
|
197
200
|
const cacheKey = hash(R.omit(['requestId', 'date'], body));
|
|
198
|
-
|
|
201
|
+
req.cacheKey = cacheKey;
|
|
199
202
|
const foundCache = await cache.get({
|
|
200
203
|
pluginName: body.params.appKey,
|
|
201
204
|
key: cacheKey,
|
|
202
205
|
});
|
|
203
206
|
if (foundCache) {
|
|
204
207
|
// console.log('foundCache', cacheKey);
|
|
205
|
-
req.customBody.usedCache = cacheKey;
|
|
206
208
|
res.json(foundCache);
|
|
207
209
|
}
|
|
208
210
|
const realSend = res.json;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ti2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"description": "Tourist Industry Exchange (TI2)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"bluebird": "^3.7.2",
|
|
29
29
|
"bull": "^4.8.2",
|
|
30
30
|
"commander": "^9.2.0",
|
|
31
|
+
"compression": "^1.7.4",
|
|
31
32
|
"eventemitter2": "^6.4.9",
|
|
32
33
|
"express": "^4.17.2",
|
|
33
34
|
"ioredis": "^5.0.4",
|