dce-expresskit 5.0.4 → 5.0.5

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.
@@ -60,22 +60,32 @@ var sendServerToServerRequest_1 = __importDefault(require("./sendServerToServerR
60
60
  * @returns the body of the response from the other server
61
61
  */
62
62
  var visitEndpointOnAnotherServer = function (opts) { return __awaiter(void 0, void 0, void 0, function () {
63
- var response, body;
64
- return __generator(this, function (_a) {
65
- switch (_a.label) {
66
- case 0: return [4 /*yield*/, (0, sendServerToServerRequest_1.default)({
67
- path: opts.path,
68
- host: opts.host,
69
- method: opts.method,
70
- params: opts.params,
71
- responseType: opts.responseType,
72
- dceKitCrossServerCredentials: opts.dceKitCrossServerCredentials,
73
- })];
63
+ var sanitizedParams, response, body;
64
+ var _a;
65
+ return __generator(this, function (_b) {
66
+ switch (_b.label) {
67
+ case 0:
68
+ sanitizedParams = {};
69
+ Object.keys((_a = opts.params) !== null && _a !== void 0 ? _a : {}).forEach(function (key) {
70
+ var _a;
71
+ var value = (_a = opts.params) === null || _a === void 0 ? void 0 : _a[key];
72
+ if (value !== undefined) {
73
+ sanitizedParams[key] = value;
74
+ }
75
+ });
76
+ return [4 /*yield*/, (0, sendServerToServerRequest_1.default)({
77
+ path: opts.path,
78
+ host: opts.host,
79
+ method: opts.method,
80
+ params: sanitizedParams,
81
+ responseType: opts.responseType,
82
+ dceKitCrossServerCredentials: opts.dceKitCrossServerCredentials,
83
+ })];
74
84
  case 1:
75
- response = _a.sent();
85
+ response = _b.sent();
76
86
  // Check for failure
77
87
  if (!response || !response.body) {
78
- throw new dce_commonkit_1.ErrorWithCode('We didn\'t get a response from the other server. Please check the network between the two connection.', dce_commonkit_1.CommonKitErrorCode.NoResponse);
88
+ throw new dce_commonkit_1.ErrorWithCode('We didn\'t get a response from the other server. Please check the network between the two servers.', dce_commonkit_1.CommonKitErrorCode.NoResponse);
79
89
  }
80
90
  if (!response.body.success) {
81
91
  // Other errors
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/visitEndpointOnAnotherServer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,+CAGuB;AAEvB,sBAAsB;AACtB,0FAAoE;AAEpE,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E;;;;;;;;;;;;GAYG;AACH,IAAM,4BAA4B,GAAG,UACnC,IAOC;;;;oBAGgB,qBAAM,IAAA,mCAAyB,EAAC;oBAC/C,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,YAAY,EAAE,IAAI,CAAC,YAAY;oBAC/B,4BAA4B,EAAE,IAAI,CAAC,4BAA4B;iBAChE,CAAC,EAAA;;gBAPI,QAAQ,GAAG,SAOf;gBAEF,oBAAoB;gBACpB,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;oBAChC,MAAM,IAAI,6BAAa,CACrB,uGAAuG,EACvG,kCAAkB,CAAC,UAAU,CAC9B,CAAC;gBACJ,CAAC;gBACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;oBAC3B,eAAe;oBACf,MAAM,IAAI,6BAAa,CACrB,CACE,QAAQ,CAAC,IAAI,CAAC,OAAO;2BAClB,qDAAqD,CACzD,EACD,CACE,QAAQ,CAAC,IAAI,CAAC,IAAI;2BACf,kCAAkB,CAAC,MAAM,CAC7B,CACF,CAAC;gBACJ,CAAC;gBAGO,IAAI,GAAK,QAAQ,CAAC,IAAI,KAAlB,CAAmB;gBAE/B,SAAS;gBACT,sBAAO,IAAI,EAAC;;;KACb,CAAC;AAEF,kBAAe,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceR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AAI,CAAC,OAAO;2BAClB,qDAAqD,CACzD,EACD,CACE,QAAQ,CAAC,IAAI,CAAC,IAAI;2BACf,kCAAkB,CAAC,MAAM,CAC7B,CACF,CAAC;gBACJ,CAAC;gBAGO,IAAI,GAAK,QAAQ,CAAC,IAAI,KAAlB,CAAmB;gBAE/B,SAAS;gBACT,sBAAO,IAAI,EAAC;;;KACb,CAAC;AAEF,kBAAe,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-expresskit",
3
- "version": "5.0.4",
3
+ "version": "5.0.5",
4
4
  "description": "Shared functions, helpers, and tools for Harvard DCE Express-based servers",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -34,12 +34,21 @@ const visitEndpointOnAnotherServer = async (
34
34
  dceKitCrossServerCredentials?: string,
35
35
  },
36
36
  ): Promise<any> => {
37
+ // Sanitize params: remove undefined values
38
+ const sanitizedParams: { [key in string]: any } = {};
39
+ Object.keys(opts.params ?? {}).forEach((key) => {
40
+ const value = opts.params?.[key];
41
+ if (value !== undefined) {
42
+ sanitizedParams[key] = value;
43
+ }
44
+ });
45
+
37
46
  // Send the request
38
47
  const response = await sendServerToServerRequest({
39
48
  path: opts.path,
40
49
  host: opts.host,
41
50
  method: opts.method,
42
- params: opts.params,
51
+ params: sanitizedParams,
43
52
  responseType: opts.responseType,
44
53
  dceKitCrossServerCredentials: opts.dceKitCrossServerCredentials,
45
54
  });
@@ -47,7 +56,7 @@ const visitEndpointOnAnotherServer = async (
47
56
  // Check for failure
48
57
  if (!response || !response.body) {
49
58
  throw new ErrorWithCode(
50
- 'We didn\'t get a response from the other server. Please check the network between the two connection.',
59
+ 'We didn\'t get a response from the other server. Please check the network between the two servers.',
51
60
  CommonKitErrorCode.NoResponse,
52
61
  );
53
62
  }