@gravity-ui/gateway 1.5.1 → 2.0.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 +1 -1
- package/build/index.js +3 -1
- package/build/utils/parse-error.d.ts +1 -3
- package/build/utils/parse-error.js +1 -3
- package/build/utils/validate.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ interface GatewayConfig {
|
|
|
116
116
|
validationSchema?: object;
|
|
117
117
|
// Enables encoding of REST path arguments.
|
|
118
118
|
encodePathArgs?: boolean;
|
|
119
|
-
// Configuration for automatic connection re-establishment upon connection error through L3 load balancer (default is
|
|
119
|
+
// Configuration for automatic connection re-establishment upon connection error through L3 load balancer (default is true).
|
|
120
120
|
grpcRecreateService?: boolean;
|
|
121
121
|
}
|
|
122
122
|
```
|
package/build/index.js
CHANGED
|
@@ -48,6 +48,7 @@ function isRestActionConfig(actionConfig) {
|
|
|
48
48
|
return Boolean(actionConfig.method);
|
|
49
49
|
}
|
|
50
50
|
function createApiAction(schema, config, serviceKey, actionName, api, grpcContext) {
|
|
51
|
+
var _a;
|
|
51
52
|
const serviceSchema = schema[serviceKey];
|
|
52
53
|
if (!serviceSchema) {
|
|
53
54
|
throw new config.ErrorConstructor(`Gateway config error. Service "${serviceKey}" have been not found.`, {
|
|
@@ -80,13 +81,14 @@ function createApiAction(schema, config, serviceKey, actionName, api, grpcContex
|
|
|
80
81
|
getAuthHeaders: config.getAuthHeaders,
|
|
81
82
|
}, config.ErrorConstructor);
|
|
82
83
|
}
|
|
84
|
+
const grpcRecreateService = (_a = config.grpcRecreateService) !== null && _a !== void 0 ? _a : true;
|
|
83
85
|
return (0, grpc_1.default)(grpcContext, endpointsConfig, action, serviceKey, actionName, {
|
|
84
86
|
serviceName,
|
|
85
87
|
timeout: config.timeout,
|
|
86
88
|
sendStats: config.sendStats,
|
|
87
89
|
proxyHeaders: config.proxyHeaders,
|
|
88
90
|
grpcOptions: config.grpcOptions,
|
|
89
|
-
grpcRecreateService
|
|
91
|
+
grpcRecreateService,
|
|
90
92
|
getAuthHeaders: config.getAuthHeaders,
|
|
91
93
|
}, config.ErrorConstructor);
|
|
92
94
|
}
|
|
@@ -9,12 +9,10 @@ export declare function parseMixedError(e: Error & {
|
|
|
9
9
|
status: number;
|
|
10
10
|
message: string;
|
|
11
11
|
code: string;
|
|
12
|
-
|
|
12
|
+
debug: {
|
|
13
13
|
originalError: Error & {
|
|
14
14
|
code?: string | undefined;
|
|
15
15
|
};
|
|
16
|
-
};
|
|
17
|
-
debug: {
|
|
18
16
|
stack: string | undefined;
|
|
19
17
|
};
|
|
20
18
|
};
|
|
@@ -14,10 +14,8 @@ function parseMixedError(e) {
|
|
|
14
14
|
status: 500,
|
|
15
15
|
message: String(e.message || DEFAULT_GATEWAY_MESSAGE),
|
|
16
16
|
code: String(e.code || DEFAULT_GATEWAY_CODE),
|
|
17
|
-
details: {
|
|
18
|
-
originalError: e,
|
|
19
|
-
},
|
|
20
17
|
debug: {
|
|
18
|
+
originalError: e,
|
|
21
19
|
stack: e.stack,
|
|
22
20
|
},
|
|
23
21
|
};
|
package/build/utils/validate.js
CHANGED
|
@@ -33,6 +33,7 @@ function getPathParam(value) {
|
|
|
33
33
|
}
|
|
34
34
|
exports.getPathParam = getPathParam;
|
|
35
35
|
function getPathArgsProxy(args, encodePathArgs) {
|
|
36
|
+
const encodePathArgsVal = encodePathArgs !== null && encodePathArgs !== void 0 ? encodePathArgs : true;
|
|
36
37
|
if (!args) {
|
|
37
38
|
return args;
|
|
38
39
|
}
|
|
@@ -47,7 +48,7 @@ function getPathArgsProxy(args, encodePathArgs) {
|
|
|
47
48
|
}
|
|
48
49
|
if (typeof value === 'string') {
|
|
49
50
|
const pathParam = getPathParam(value);
|
|
50
|
-
return
|
|
51
|
+
return encodePathArgsVal ? encodeURIComponent(pathParam) : pathParam;
|
|
51
52
|
}
|
|
52
53
|
return value; // TODO return error INVALID_PARAMS
|
|
53
54
|
},
|