node-pluginsmanager-plugin 6.1.0 → 6.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.
@@ -341,7 +341,8 @@ class Server extends MediatorUser_1.default {
341
341
  });
342
342
  }
343
343
  else {
344
- this._log("success", "<= [" + req.validatedIp + "] " + JSON.stringify(content));
344
+ this._log("success", "<= [" + req.validatedIp + "] "
345
+ + (Buffer.isBuffer(content) ? "Buffer" : JSON.stringify(content)));
345
346
  return (0, send_1.default)(req, res, serverCodes_1.default.OK_PUT, content, {
346
347
  "apiVersion": apiVersion,
347
348
  "cors": this._cors,
@@ -359,7 +360,8 @@ class Server extends MediatorUser_1.default {
359
360
  });
360
361
  }
361
362
  else {
362
- this._log("success", "<= [" + req.validatedIp + "] " + JSON.stringify(content));
363
+ this._log("success", "<= [" + req.validatedIp + "] "
364
+ + (Buffer.isBuffer(content) ? "Buffer" : JSON.stringify(content)));
363
365
  return (0, send_1.default)(req, res, serverCodes_1.default.OK, content, {
364
366
  "apiVersion": apiVersion,
365
367
  "cors": this._cors,
@@ -1 +1 @@
1
- export default function cleanSendedError(data: any): string;
1
+ export default function cleanSendedError(data: Error | Record<string, any> | string | null): Record<string, any> | string | null;
@@ -1,2 +1,2 @@
1
- import { OpenApiDocument } from "express-openapi-validate";
1
+ import type { OpenApiDocument } from "express-openapi-validate";
2
2
  export default function extractPattern(paths: OpenApiDocument["paths"], pathname: string, method: string): string;
@@ -1,2 +1,2 @@
1
- import { OpenAPIV3_1 } from "openapi-types";
1
+ import type { OpenAPIV3_1 } from "openapi-types";
2
2
  export default function extractSchemaType(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject, schemas: Record<string, any>): "boolean" | "object" | "number" | "string" | "integer" | "array";
@@ -31,13 +31,13 @@ function send(req, res, code, content, options) {
31
31
  }
32
32
  return result;
33
33
  }
34
- }).then((stringifiedContent) => {
34
+ }).then((formattedContent) => {
35
35
  return new Promise((resolve) => {
36
36
  // force data for checking
37
37
  res.statusCode = code;
38
38
  res.headers = Object.assign({
39
39
  "Content-Type": options.mime,
40
- "Content-Length": stringifiedContent ? Buffer.byteLength(stringifiedContent) : 0,
40
+ "Content-Length": formattedContent ? Buffer.byteLength(formattedContent) : 0,
41
41
  "Status-Code-Url-Cat": "https://http.cat/" + code,
42
42
  "API-Version": options.apiVersion
43
43
  }, options.cors ? {
@@ -71,9 +71,14 @@ function send(req, res, code, content, options) {
71
71
  } : {});
72
72
  // send data
73
73
  res.writeHead(res.statusCode, res.headers);
74
- if ("" !== stringifiedContent) {
74
+ if ("string" === typeof formattedContent) {
75
75
  res.body = content; // for Mediator response validator
76
- res.end(stringifiedContent, "utf-8", () => {
76
+ res.end(formattedContent, "utf-8", () => {
77
+ resolve();
78
+ });
79
+ }
80
+ else if (Buffer.isBuffer(formattedContent)) {
81
+ res.end(formattedContent, () => {
77
82
  resolve();
78
83
  });
79
84
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "node-pluginsmanager-plugin",
4
- "version": "6.1.0",
4
+ "version": "6.2.0",
5
5
  "description": "An abstract parent plugin for node-pluginsmanager",
6
6
 
7
7
  "type": "commonjs",