node-pluginsmanager-plugin 6.2.1 → 6.2.3

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.
@@ -88,14 +88,14 @@ class Mediator extends DescriptorUser_1.default {
88
88
  return !foundPathMethod ? Promise.reject(new ReferenceError("Unknown operationId \"" + operationId + "\"")) : new Promise((resolve, reject) => {
89
89
  // no content, no validation
90
90
  if (204 === res.statusCode) {
91
- return "undefined" !== typeof res.body && "" !== res.body.trim() ? reject(new ReferenceError("You should not have content data with 204 statusCode")) : resolve();
91
+ return "undefined" !== typeof res.body && "" !== res.body ? reject(new ReferenceError("You should not have content data with 204 statusCode")) : resolve();
92
92
  }
93
93
  // no content, no validation (put requests)
94
94
  else if (201 === res.statusCode && "undefined" === typeof res.body) {
95
95
  return resolve();
96
96
  }
97
97
  // validator cannot correctly check pure boolean return
98
- else if ("undefined" !== typeof res.body && ["true", "false"].includes(res.body.trim())) {
98
+ else if ("undefined" !== typeof res.body && ["true", "false"].includes(res.body)) {
99
99
  return resolve();
100
100
  }
101
101
  else {
@@ -330,42 +330,34 @@ class Server extends MediatorUser_1.default {
330
330
  });
331
331
  // send response
332
332
  }).then((content) => {
333
- // created
334
- if ("put" === req.method) {
335
- if ("undefined" === typeof content || null === content) {
336
- this._log("success", "<= [" + req.validatedIp + "] no content");
337
- return (0, send_1.default)(req, res, serverCodes_1.default.OK_PUT, "", {
338
- "apiVersion": apiVersion,
339
- "cors": this._cors,
340
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.OK_PUT, responses)
341
- });
342
- }
343
- else {
344
- this._log("success", "<= [" + req.validatedIp + "] "
345
- + (Buffer.isBuffer(content) ? "Buffer" : JSON.stringify(content)));
346
- return (0, send_1.default)(req, res, serverCodes_1.default.OK_PUT, content, {
347
- "apiVersion": apiVersion,
348
- "cors": this._cors,
349
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.OK_PUT, responses)
350
- });
351
- }
352
- }
353
333
  // no content
354
- else if ("undefined" === typeof content || null === content) {
355
- this._log("warning", "<= [" + req.validatedIp + "] no content");
356
- return (0, send_1.default)(req, res, serverCodes_1.default.OK_NO_CONTENT, "", {
334
+ if ("undefined" === typeof content || null === content) {
335
+ this._log("success", "<= [" + req.validatedIp + "] no content");
336
+ const serverCode = "put" === req.method ? serverCodes_1.default.OK_PUT : serverCodes_1.default.OK_NO_CONTENT;
337
+ return (0, send_1.default)(req, res, serverCode, "", {
357
338
  "apiVersion": apiVersion,
358
339
  "cors": this._cors,
359
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.OK_NO_CONTENT, responses)
340
+ "mime": (0, extractMime_1.default)(contentType, serverCode, responses)
360
341
  });
361
342
  }
362
343
  else {
363
- this._log("success", "<= [" + req.validatedIp + "] "
364
- + (Buffer.isBuffer(content) ? "Buffer" : JSON.stringify(content)));
365
- return (0, send_1.default)(req, res, serverCodes_1.default.OK, content, {
344
+ if (Buffer.isBuffer(content)) {
345
+ this._log("success", "<= [" + req.validatedIp + "] <" + contentType + "> Buffer");
346
+ }
347
+ else if ("application/json" === contentType) {
348
+ this._log("success", "<= [" + req.validatedIp + "] <" + contentType + "> " + JSON.stringify(content));
349
+ }
350
+ else if (["application/xml", "text/plain"].includes(contentType)) {
351
+ this._log("success", "<= [" + req.validatedIp + "] <" + contentType + "> " + content);
352
+ }
353
+ else {
354
+ this._log("success", "<= [" + req.validatedIp + "] <" + contentType + "> ...");
355
+ }
356
+ const serverCode = "put" === req.method ? serverCodes_1.default.OK_PUT : serverCodes_1.default.OK;
357
+ return (0, send_1.default)(req, res, serverCode, content, {
366
358
  "apiVersion": apiVersion,
367
359
  "cors": this._cors,
368
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.OK, responses)
360
+ "mime": (0, extractMime_1.default)(contentType, serverCode, responses)
369
361
  });
370
362
  }
371
363
  }).catch((err) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "node-pluginsmanager-plugin",
4
- "version": "6.2.1",
4
+ "version": "6.2.3",
5
5
  "description": "An abstract parent plugin for node-pluginsmanager",
6
6
 
7
7
  "type": "commonjs",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/express": "4.17.21",
52
- "@types/node": "20.11.10",
52
+ "@types/node": "20.11.16",
53
53
  "@types/socket.io": "3.0.2",
54
54
  "@types/uniqid": "5.3.4",
55
55
  "@types/ws": "8.5.10",
@@ -57,7 +57,7 @@
57
57
  "colors": "1.4.0",
58
58
  "eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
59
59
  "express": "4.18.2",
60
- "husky": "9.0.7",
60
+ "husky": "9.0.10",
61
61
  "mocha": "10.2.0",
62
62
  "nyc": "15.1.0",
63
63
  "openapi-types": "12.1.3",