node-pluginsmanager-plugin 6.0.3 → 6.1.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.
Files changed (56) hide show
  1. package/lib/cjs/checkers/RangeError/checkArrayLength.js +1 -3
  2. package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.js +1 -3
  3. package/lib/cjs/checkers/RangeError/checkIntegerBetween.js +1 -3
  4. package/lib/cjs/checkers/RangeError/checkNonEmptyArray.js +1 -3
  5. package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.js +1 -3
  6. package/lib/cjs/checkers/RangeError/checkNonEmptyNumber.js +1 -3
  7. package/lib/cjs/checkers/RangeError/checkNonEmptyObject.js +1 -3
  8. package/lib/cjs/checkers/RangeError/checkNonEmptyString.js +1 -3
  9. package/lib/cjs/checkers/RangeError/checkNumberBetween.js +1 -3
  10. package/lib/cjs/checkers/RangeError/checkObjectLength.js +1 -3
  11. package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.js +1 -3
  12. package/lib/cjs/checkers/RangeError/checkStringLength.js +1 -3
  13. package/lib/cjs/checkers/RangeError/checkStringLengthBetween.js +1 -3
  14. package/lib/cjs/checkers/ReferenceError/checkExists.js +1 -3
  15. package/lib/cjs/checkers/TypeError/checkArray.js +1 -3
  16. package/lib/cjs/checkers/TypeError/checkBoolean.js +1 -3
  17. package/lib/cjs/checkers/TypeError/checkFunction.js +1 -3
  18. package/lib/cjs/checkers/TypeError/checkInteger.js +1 -3
  19. package/lib/cjs/checkers/TypeError/checkNumber.js +1 -3
  20. package/lib/cjs/checkers/TypeError/checkObject.js +1 -3
  21. package/lib/cjs/checkers/TypeError/checkString.js +1 -3
  22. package/lib/cjs/components/DescriptorUser.d.ts +1 -1
  23. package/lib/cjs/components/DescriptorUser.js +22 -14
  24. package/lib/cjs/components/Mediator.d.ts +6 -14
  25. package/lib/cjs/components/Mediator.js +144 -147
  26. package/lib/cjs/components/MediatorUser.d.ts +1 -1
  27. package/lib/cjs/components/MediatorUser.js +4 -4
  28. package/lib/cjs/components/NotFoundError.js +1 -2
  29. package/lib/cjs/components/Orchestrator.d.ts +7 -8
  30. package/lib/cjs/components/Orchestrator.js +7 -9
  31. package/lib/cjs/components/Server.d.ts +14 -22
  32. package/lib/cjs/components/Server.js +40 -31
  33. package/lib/cjs/main.cjs +1 -1
  34. package/lib/cjs/main.d.cts +7 -7
  35. package/lib/cjs/utils/cleanSendedError.js +1 -2
  36. package/lib/cjs/utils/descriptor/extractParams.d.ts +1 -3
  37. package/lib/cjs/utils/descriptor/extractParams.js +1 -2
  38. package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.js +1 -2
  39. package/lib/cjs/utils/descriptor/extractPattern.js +4 -4
  40. package/lib/cjs/utils/descriptor/extractSchemaType.d.ts +1 -3
  41. package/lib/cjs/utils/descriptor/extractSchemaType.js +1 -1
  42. package/lib/cjs/utils/file/checkFile.js +4 -4
  43. package/lib/cjs/utils/file/isFile.js +1 -2
  44. package/lib/cjs/utils/file/readJSONFile.js +1 -2
  45. package/lib/cjs/utils/jsonParser.js +1 -2
  46. package/lib/cjs/utils/removeFirstSlash.js +1 -2
  47. package/lib/cjs/utils/request/extractBody.d.ts +1 -1
  48. package/lib/cjs/utils/request/extractBody.js +4 -5
  49. package/lib/cjs/utils/request/extractCookies.d.ts +1 -3
  50. package/lib/cjs/utils/request/extractCookies.js +1 -1
  51. package/lib/cjs/utils/request/extractIp.js +1 -2
  52. package/lib/cjs/utils/request/extractMime.d.ts +4 -8
  53. package/lib/cjs/utils/request/extractMime.js +4 -11
  54. package/lib/cjs/utils/send.d.ts +6 -6
  55. package/lib/cjs/utils/send.js +88 -84
  56. package/package.json +97 -91
@@ -1,84 +1,88 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // module
4
- function send(req, res, code, content, options) {
5
- return Promise.resolve().then(() => {
6
- if (!content) {
7
- return "";
8
- }
9
- else {
10
- let result = "";
11
- if (options.mime.includes("application/json")) {
12
- if ("string" === typeof content) {
13
- try {
14
- JSON.parse(content); // is content json & parseable ?
15
- result = content; // yes => valid JSON string, send it as it is
16
- }
17
- catch (e) {
18
- result = JSON.stringify(content); // no => not JSON string, send formatted one
19
- }
20
- }
21
- else {
22
- const stringified = JSON.stringify(content);
23
- if (stringified !== content) {
24
- result = stringified;
25
- }
26
- }
27
- }
28
- else {
29
- result = content;
30
- }
31
- return result;
32
- }
33
- }).then((stringifiedContent) => {
34
- return new Promise((resolve) => {
35
- // force data for checking
36
- res.statusCode = code;
37
- res.headers = Object.assign({
38
- "Content-Type": options.mime,
39
- "Content-Length": stringifiedContent ? Buffer.byteLength(stringifiedContent) : 0,
40
- "Status-Code-Url-Cat": "https://http.cat/" + code,
41
- "API-Version": options.apiVersion
42
- }, options.cors ? {
43
- "Access-Control-Allow-Origin": "*",
44
- "Access-Control-Allow-Credentials": true,
45
- "Access-Control-Allow-Methods": req.headers["access-control-request-method"] ? req.headers["access-control-request-method"] : [
46
- "GET",
47
- "POST",
48
- "PUT",
49
- "DELETE",
50
- "PATCH",
51
- "OPTIONS"
52
- ].join(", "),
53
- "Access-Control-Allow-Headers": req.headers["access-control-request-headers"] ? req.headers["access-control-request-headers"] : [
54
- "Origin",
55
- "Accept",
56
- "Accept-Version",
57
- "Content-Length",
58
- "Content-MD5",
59
- "Content-Type",
60
- "Date",
61
- "X-Api-Version",
62
- "X-File-Name",
63
- "X-CSRF-Token",
64
- "X-Requested-With"
65
- ].join(", ")
66
- } : {});
67
- // send data
68
- res.writeHead(res.statusCode, res.headers);
69
- if ("" !== stringifiedContent) {
70
- res.body = content; // for Mediator response validator
71
- res.end(stringifiedContent, "utf-8", () => {
72
- resolve();
73
- });
74
- }
75
- else {
76
- res.end(() => {
77
- resolve();
78
- });
79
- }
80
- });
81
- });
82
- }
83
- exports.default = send;
84
- ;
1
+ "use strict";
2
+ // types & interfaces
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ // module
5
+ function send(req, res, code, content, options) {
6
+ return Promise.resolve().then(() => {
7
+ if (!content) {
8
+ return "";
9
+ }
10
+ else {
11
+ let result = "";
12
+ if (options.mime.includes("application/json")) {
13
+ if ("string" === typeof content) {
14
+ try {
15
+ JSON.parse(content); // is content json & parseable ?
16
+ result = content; // yes => valid JSON string, send it as it is
17
+ }
18
+ catch (e) {
19
+ result = JSON.stringify(content); // no => not JSON string, send formatted one
20
+ }
21
+ }
22
+ else {
23
+ const stringified = JSON.stringify(content);
24
+ if (stringified !== content) {
25
+ result = stringified;
26
+ }
27
+ }
28
+ }
29
+ else {
30
+ result = content;
31
+ }
32
+ return result;
33
+ }
34
+ }).then((stringifiedContent) => {
35
+ return new Promise((resolve) => {
36
+ // force data for checking
37
+ res.statusCode = code;
38
+ res.headers = Object.assign({
39
+ "Content-Type": options.mime,
40
+ "Content-Length": stringifiedContent ? Buffer.byteLength(stringifiedContent) : 0,
41
+ "Status-Code-Url-Cat": "https://http.cat/" + code,
42
+ "API-Version": options.apiVersion
43
+ }, options.cors ? {
44
+ "Access-Control-Allow-Origin": "*",
45
+ "Access-Control-Allow-Credentials": true,
46
+ "Access-Control-Allow-Methods": req.headers["access-control-request-method"]
47
+ ? req.headers["access-control-request-method"]
48
+ : [
49
+ "GET",
50
+ "POST",
51
+ "PUT",
52
+ "DELETE",
53
+ "PATCH",
54
+ "OPTIONS"
55
+ ].join(", "),
56
+ "Access-Control-Allow-Headers": req.headers["access-control-request-headers"]
57
+ ? req.headers["access-control-request-headers"]
58
+ : [
59
+ "Origin",
60
+ "Accept",
61
+ "Accept-Version",
62
+ "Content-Length",
63
+ "Content-MD5",
64
+ "Content-Type",
65
+ "Date",
66
+ "X-Api-Version",
67
+ "X-File-Name",
68
+ "X-CSRF-Token",
69
+ "X-Requested-With"
70
+ ].join(", ")
71
+ } : {});
72
+ // send data
73
+ res.writeHead(res.statusCode, res.headers);
74
+ if ("" !== stringifiedContent) {
75
+ res.body = content; // for Mediator response validator
76
+ res.end(stringifiedContent, "utf-8", () => {
77
+ resolve();
78
+ });
79
+ }
80
+ else {
81
+ res.end(() => {
82
+ resolve();
83
+ });
84
+ }
85
+ });
86
+ });
87
+ }
88
+ exports.default = send;
package/package.json CHANGED
@@ -1,91 +1,97 @@
1
- {
2
-
3
- "name": "node-pluginsmanager-plugin",
4
- "version": "6.0.3",
5
- "description": "An abstract parent plugin for node-pluginsmanager",
6
-
7
- "type": "commonjs",
8
- "typings": "./lib/cjs/main.d.cts",
9
- "main": "./lib/cjs/main.cjs",
10
-
11
- "exports": {
12
- ".": {
13
- "require": {
14
- "types": "./lib/cjs/main.d.cts",
15
- "default": "./lib/cjs/main.cjs"
16
- }
17
- }
18
- },
19
-
20
- "scripts": {
21
-
22
- "build": "node ./removeOldBuild.js && npx tsc --project \"./tsconfig.json\"",
23
-
24
- "lint": "npx eslint ./test/**/*.js",
25
- "check-requires": "npx used-deps-analyzer \"./package.json\" \"./src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
26
- "check-updates": "npx check-version-modules",
27
- "unit-tests": "npm run build && npx nyc --reporter=html --reporter=text mocha",
28
-
29
- "tests": "npm run-script lint && npm run check-requires && npm run-script check-updates && npm run-script unit-tests",
30
- "ci": "npm run-script tests && npx nyc report --reporter=text-lcov | coveralls"
31
-
32
- },
33
-
34
- "files": [
35
- "/lib"
36
- ],
37
- "engines": {
38
- "node": ">=16.0.0"
39
- },
40
-
41
- "dependencies": {
42
- "@apidevtools/swagger-parser": "10.1.0",
43
- "express-openapi-validate": "0.6.1",
44
- "uniqid": "5.4.0"
45
- },
46
- "devDependencies": {
47
- "@types/express": "4.17.21",
48
- "@types/node": "20.10.3",
49
- "@types/socket.io": "3.0.2",
50
- "@types/uniqid": "5.3.4",
51
- "@types/ws": "8.5.10",
52
- "check-version-modules": "2.0.0",
53
- "coveralls": "3.1.1",
54
- "colors": "1.4.0",
55
- "eslint": "8.55.0",
56
- "express": "4.18.2",
57
- "husky": "8.0.3",
58
- "mocha": "10.2.0",
59
- "nyc": "15.1.0",
60
- "openapi-types": "12.1.3",
61
- "socket.io": "4.7.2",
62
- "socket.io-client": "4.7.2",
63
- "typescript": "5.3.2",
64
- "used-deps-analyzer": "0.1.8",
65
- "ws": "8.14.2"
66
- },
67
- "optionalDependencies": {},
68
-
69
- "husky": {
70
- "hooks": {
71
- "pre-push": "npm run-script tests"
72
- }
73
- },
74
- "keywords": [
75
- "plugin",
76
- "manage",
77
- "gestion"
78
- ],
79
- "author": "Sébastien VIDAL",
80
- "license": "ISC",
81
-
82
- "homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
83
- "repository": {
84
- "type": "git",
85
- "url": "git://github.com/Psychopoulet/node-pluginsmanager-plugin"
86
- },
87
- "bugs": {
88
- "url": "https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues"
89
- }
90
-
91
- }
1
+ {
2
+
3
+ "name": "node-pluginsmanager-plugin",
4
+ "version": "6.1.0",
5
+ "description": "An abstract parent plugin for node-pluginsmanager",
6
+
7
+ "type": "commonjs",
8
+ "typings": "./lib/cjs/main.d.cts",
9
+ "main": "./lib/cjs/main.cjs",
10
+
11
+ "exports": {
12
+ ".": {
13
+ "require": {
14
+ "types": "./lib/cjs/main.d.cts",
15
+ "default": "./lib/cjs/main.cjs"
16
+ }
17
+ }
18
+ },
19
+
20
+ "scripts": {
21
+
22
+ "prepare": "npx husky install",
23
+
24
+ "clean": "npx rimraf lib",
25
+ "build": "npm run-script clean && npx tsc --project \"./tsconfig.json\"",
26
+
27
+ "lint": "npx eslint --config .eslintrc-src.js --ext .cts,.ts ./src/**/* && npx eslint --config .eslintrc-tests.js ./bin/*.js ./test/**/*.js",
28
+ "check-requires": "npx used-deps-analyzer \"./package.json\" \"./src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
29
+ "check-updates": "npx check-version-modules",
30
+ "unit-tests": "npm run-script build && npx nyc --reporter=html --reporter=text mocha",
31
+
32
+ "tests": "npm run-script lint && npm run-script check-requires && npm run-script check-updates && npm run-script unit-tests"
33
+
34
+ },
35
+
36
+ "files": [
37
+ "/bin",
38
+ "/lib",
39
+ "/public"
40
+ ],
41
+ "engines": {
42
+ "node": ">=16.0.0"
43
+ },
44
+
45
+ "dependencies": {
46
+ "@apidevtools/swagger-parser": "10.1.0",
47
+ "express-openapi-validate": "0.6.1",
48
+ "uniqid": "5.4.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/express": "4.17.21",
52
+ "@types/node": "20.11.10",
53
+ "@types/socket.io": "3.0.2",
54
+ "@types/uniqid": "5.3.4",
55
+ "@types/ws": "8.5.10",
56
+ "check-version-modules": "2.0.0",
57
+ "colors": "1.4.0",
58
+ "eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
59
+ "express": "4.18.2",
60
+ "husky": "9.0.7",
61
+ "mocha": "10.2.0",
62
+ "nyc": "15.1.0",
63
+ "openapi-types": "12.1.3",
64
+ "rimraf": "5.0.5",
65
+ "socket.io": "4.7.4",
66
+ "socket.io-client": "4.7.4",
67
+ "typescript": "5.3.3",
68
+ "used-deps-analyzer": "0.1.8",
69
+ "ws": "8.16.0"
70
+ },
71
+ "optionalDependencies": {},
72
+
73
+ "husky": {
74
+ "hooks": {
75
+ "pre-commit": "npm run-script lint",
76
+ "pre-push": "npm run-script unit-tests",
77
+ "pre-receive": "npm run-script tests"
78
+ }
79
+ },
80
+ "keywords": [
81
+ "plugin",
82
+ "manage",
83
+ "gestion"
84
+ ],
85
+ "author": "Sébastien VIDAL",
86
+ "license": "ISC",
87
+
88
+ "homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
89
+ "repository": {
90
+ "type": "git",
91
+ "url": "git://github.com/Psychopoulet/node-pluginsmanager-plugin"
92
+ },
93
+ "bugs": {
94
+ "url": "https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues"
95
+ }
96
+
97
+ }