node-pluginsmanager-plugin 4.8.2 → 4.8.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.
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ // module
4
+
5
+ module.exports = class NotFoundError extends Error {};
@@ -16,6 +16,7 @@
16
16
 
17
17
  // locals
18
18
  const MediatorUser = require(join(__dirname, "MediatorUser.js"));
19
+ const NotFoundError = require(join(__dirname, "NotFoundError.js"));
19
20
  const { checkInteger, checkNonEmptyObject, checkNonEmptyString } = require(join(__dirname, "..", "checkers", "main.js"));
20
21
  const { extractPattern, extractParams, extractSchemaType } = require(join(__dirname, "..", "utils", "descriptor", "main.js"));
21
22
  const { extractBody, extractIp, extractCookies } = require(join(__dirname, "..", "utils", "request", "main.js"));
@@ -120,12 +121,15 @@ module.exports = class Server extends MediatorUser {
120
121
  req.params = !checkNonEmptyObject("params", req.params, false) ? req.params : extractParams(req.pattern, pathname);
121
122
 
122
123
  // ensure content length formate
123
- if ("string" === typeof req.headers["content-length"]) {
124
+ if ("undefined" === typeof req.headers["content-length"]) {
125
+ req.headers["content-length"] = 0;
126
+ }
127
+ else if ("string" === typeof req.headers["content-length"]) {
124
128
  req.headers["content-length"] = parseInt(req.headers["content-length"], 10);
125
129
  }
126
130
 
127
- // set default content-typ
128
- if ("string" !== typeof req.headers["content-length"]) {
131
+ // set default content-type
132
+ if ("string" !== typeof req.headers["content-type"]) {
129
133
  req.headers["content-type"] = "application/json";
130
134
  }
131
135
 
@@ -486,6 +490,17 @@ module.exports = class Server extends MediatorUser {
486
490
  this._log("error", "<= [" + req.validatedIp + "] " + JSON.stringify(result));
487
491
  return send(req, res, SERVER_CODES.JSON_PARSE, result, this._Descriptor.info.version, this._cors);
488
492
 
493
+ }
494
+ else if (err instanceof NotFoundError) {
495
+
496
+ const result = {
497
+ "code": "NOT_FOUND",
498
+ "message": cleanSendedError(err)
499
+ };
500
+
501
+ this._log("error", "<= [" + req.validatedIp + "] " + JSON.stringify(result));
502
+ return send(req, res, SERVER_CODES.NOT_FOUND, result, this._Descriptor.info.version, this._cors);
503
+
489
504
  }
490
505
  else {
491
506
 
@@ -11,6 +11,7 @@
11
11
  const MediatorUser = require(join(__dirname, "MediatorUser.js"));
12
12
  const Orchestrator = require(join(__dirname, "Orchestrator.js"));
13
13
  const Server = require(join(__dirname, "Server.js"));
14
+ const NotFoundError = require(join(__dirname, "NotFoundError.js"));
14
15
 
15
16
  // module
16
17
 
@@ -19,5 +20,6 @@ module.exports = {
19
20
  Mediator,
20
21
  MediatorUser,
21
22
  Orchestrator,
22
- Server
23
+ Server,
24
+ NotFoundError
23
25
  };
package/lib/index.d.ts CHANGED
@@ -195,8 +195,8 @@ declare module "node-pluginsmanager-plugin" {
195
195
 
196
196
  // init / release
197
197
 
198
- public load(): Promise<void>;
199
- public destroy(): Promise<void>;
198
+ public load(data?: any): Promise<void>;
199
+ public destroy(data?: any): Promise<void>;
200
200
 
201
201
  // write
202
202
 
@@ -206,4 +206,6 @@ declare module "node-pluginsmanager-plugin" {
206
206
 
207
207
  }
208
208
 
209
+ export class NotFoundError extends Error {}
210
+
209
211
  }
@@ -8,6 +8,7 @@
8
8
  "WRONG_TYPE_PARAMETER": 400,
9
9
  "EMPTY_OR_RANGE_OR_ENUM_PARAMETER": 400,
10
10
  "JSON_PARSE": 400,
11
+ "NOT_FOUND": 404,
11
12
  "MISSING_HEADER": 411,
12
13
 
13
14
  "INTERNAL_SERVER_ERROR": 500,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-pluginsmanager-plugin",
3
- "version": "4.8.2",
3
+ "version": "4.8.5",
4
4
  "description": "An abstract parent plugin for node-pluginsmanager",
5
5
  "main": "lib/main.js",
6
6
  "typings": "lib/index.d.ts",
@@ -35,25 +35,25 @@
35
35
  "url": "https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@apidevtools/swagger-parser": "10.0.3",
38
+ "@apidevtools/swagger-parser": "10.1.0",
39
39
  "express-openapi-validate": "0.6.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@types/node": "17.0.25",
42
+ "@types/node": "17.0.34",
43
43
  "@types/socket.io": "3.0.2",
44
44
  "@types/ws": "8.5.3",
45
45
  "check-version-modules": "1.3.5",
46
46
  "coveralls": "3.1.1",
47
47
  "colors": "1.4.0",
48
- "eslint": "8.13.0",
49
- "express": "4.17.3",
50
- "husky": "7.0.4",
51
- "mocha": "9.2.2",
48
+ "eslint": "8.15.0",
49
+ "express": "4.18.1",
50
+ "husky": "8.0.1",
51
+ "mocha": "10.0.0",
52
52
  "nyc": "15.1.0",
53
- "socket.io": "4.4.1",
54
- "socket.io-client": "4.4.1",
55
- "typescript": "4.6.3",
56
- "ws": "8.5.0"
53
+ "socket.io": "4.5.1",
54
+ "socket.io-client": "4.5.1",
55
+ "typescript": "4.6.4",
56
+ "ws": "8.6.0"
57
57
  },
58
58
  "homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
59
59
  "engines": {
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- // module
4
-
5
- module.exports = function errToString (err) {
6
-
7
- if ("string" === typeof err) {
8
- return err;
9
- }
10
- else if ("object" === typeof err && err.message) {
11
- return err.message;
12
- }
13
- else {
14
- return "";
15
- }
16
-
17
- };