@gravity-ui/gateway 1.1.0 → 1.2.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gravity-ui/gateway · [![npm package](https://img.shields.io/npm/v/@gravity-ui/gateway)](https://www.npmjs.com/package/@gravity-ui/gateway) [![CI](https://img.shields.io/github/actions/workflow/status/gravity-ui/gateway/.github/workflows/ci.yml?label=CI&logo=github)](https://github.com/gravity-ui/gateway/actions/workflows/ci.yml?query=branch:main)
2
2
 
3
- Express controller for working with REST/GRPC APIs
3
+ Express controller for working with REST/GRPC APIs.
4
4
 
5
5
  ## Install
6
6
 
@@ -31,7 +31,7 @@ Next, the controller described above should be connected to a route of the follo
31
31
 
32
32
  ```javascript
33
33
  {
34
- 'POST /<prefix>/:scope/:service/:action': {target: '<controller>', afterAuth: ['blackbox', 'credentials']}
34
+ 'POST /<prefix>/:scope/:service/:action': {target: '<controller>', afterAuth: ['credentials']}
35
35
  }
36
36
  ```
37
37
 
@@ -48,7 +48,6 @@ function createMixedAction(config, api, serviceName, actionName, extra, ErrorCon
48
48
  (0, common_1.handleError)(ErrorConstructor, e, ctx, 'Request failed', {
49
49
  actionName,
50
50
  serviceName,
51
- parsedError,
52
51
  });
53
52
  throw {
54
53
  error: parsedError,
@@ -39,7 +39,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
39
39
  const defaultAxiosClient = (0, axios_1.getAxiosClient)(timeout, config === null || config === void 0 ? void 0 : config.retries, options === null || options === void 0 ? void 0 : options.axiosConfig);
40
40
  /* eslint-disable complexity */
41
41
  return async function action(actionConfig) {
42
- var _a, _b, _c, _d;
42
+ var _a, _b, _c, _d, _e, _f;
43
43
  const { args, requestId, headers: requestHeaders, ctx: parentCtx, authArgs } = actionConfig;
44
44
  const debugHeaders = {};
45
45
  const lang = requestHeaders[constants_1.DEFAULT_LANG_HEADER] || constants_1.Lang.Ru; // header might be empty string
@@ -187,7 +187,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
187
187
  const startRequestTime = Date.now();
188
188
  let axiosClient = defaultAxiosClient;
189
189
  if (actionConfig.timeout || endpointAxiosConfig) {
190
- const customActionTimeout = (_c = actionConfig.timeout) !== null && _c !== void 0 ? _c : timeout;
190
+ const customActionTimeout = (_e = (_d = (_c = actionConfig.timeout) !== null && _c !== void 0 ? _c : config.timeout) !== null && _d !== void 0 ? _d : endpointAxiosConfig.timeout) !== null && _e !== void 0 ? _e : timeout;
191
191
  const customActionAxiosConfig = Object.assign(Object.assign({}, ((options === null || options === void 0 ? void 0 : options.axiosConfig) || {})), (endpointAxiosConfig || {}));
192
192
  axiosClient = (0, axios_1.getAxiosClient)(customActionTimeout, config === null || config === void 0 ? void 0 : config.retries, customActionAxiosConfig);
193
193
  }
@@ -269,7 +269,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
269
269
  }
270
270
  const responseStatus = lodash_1.default.get(parsedError, 'status') || lodash_1.default.get(error, 'status', 500);
271
271
  if (options === null || options === void 0 ? void 0 : options.sendStats) {
272
- options.sendStats(Object.assign(Object.assign({}, requestData), { responseSize: getRestResponseSize((_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data, ctx, ErrorConstructor), restStatus: responseStatus }), (0, redact_sensitive_headers_1.redactSensitiveHeaders)(parentCtx, headers), parentCtx, { debugHeaders: (0, common_1.sanitizeDebugHeaders)(debugHeaders) });
272
+ options.sendStats(Object.assign(Object.assign({}, requestData), { responseSize: getRestResponseSize((_f = error === null || error === void 0 ? void 0 : error.response) === null || _f === void 0 ? void 0 : _f.data, ctx, ErrorConstructor), restStatus: responseStatus }), (0, redact_sensitive_headers_1.redactSensitiveHeaders)(parentCtx, headers), parentCtx, { debugHeaders: (0, common_1.sanitizeDebugHeaders)(debugHeaders) });
273
273
  }
274
274
  else {
275
275
  ctx.stats(Object.assign(Object.assign({}, requestData), { responseStatus }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/gateway",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",