node-pluginsmanager-plugin 7.2.0 → 7.3.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.
|
@@ -27,10 +27,8 @@ const extractMime_1 = __importDefault(require("../utils/request/extractMime"));
|
|
|
27
27
|
const send_1 = __importDefault(require("../utils/send"));
|
|
28
28
|
const cleanSendedError_1 = __importDefault(require("../utils/cleanSendedError"));
|
|
29
29
|
const MediatorUser_1 = __importDefault(require("./MediatorUser"));
|
|
30
|
-
const UnauthorizedError_1 = __importDefault(require("./errors/UnauthorizedError"));
|
|
31
|
-
const NotFoundError_1 = __importDefault(require("./errors/NotFoundError"));
|
|
32
|
-
const LockedError_1 = __importDefault(require("./errors/LockedError"));
|
|
33
30
|
const serverCodes_1 = __importDefault(require("../utils/serverCodes"));
|
|
31
|
+
const formateError_1 = __importDefault(require("../utils/server/formateError"));
|
|
34
32
|
const getServerTypeFromServer_1 = __importDefault(require("../utils/server/getServerTypeFromServer"));
|
|
35
33
|
const getSocketIOVersionFromServer_1 = __importDefault(require("../utils/server/getSocketIOVersionFromServer"));
|
|
36
34
|
// consts
|
|
@@ -416,104 +414,19 @@ class Server extends MediatorUser_1.default {
|
|
|
416
414
|
}).then((response) => {
|
|
417
415
|
return this._checkResponse ? this._Mediator.checkResponse(operationId, response) : Promise.resolve();
|
|
418
416
|
}).catch((err) => {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
else if (err instanceof TypeError) {
|
|
433
|
-
const result = JSON.stringify({
|
|
434
|
-
"code": "WRONG_TYPE_PARAMETER",
|
|
435
|
-
"message": (0, cleanSendedError_1.default)(err)
|
|
436
|
-
});
|
|
437
|
-
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
438
|
-
return (0, send_1.default)(req, res, serverCodes_1.default.WRONG_TYPE_PARAMETER, result, {
|
|
439
|
-
"apiVersion": apiVersion,
|
|
440
|
-
"cors": this._cors,
|
|
441
|
-
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.WRONG_TYPE_PARAMETER, responses)
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
else if (err instanceof RangeError) {
|
|
445
|
-
const result = JSON.stringify({
|
|
446
|
-
"code": "EMPTY_OR_RANGE_OR_ENUM_PARAMETER",
|
|
447
|
-
"message": (0, cleanSendedError_1.default)(err)
|
|
448
|
-
});
|
|
449
|
-
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
450
|
-
return (0, send_1.default)(req, res, serverCodes_1.default.EMPTY_OR_RANGE_OR_ENUM_PARAMETER, result, {
|
|
451
|
-
"apiVersion": apiVersion,
|
|
452
|
-
"cors": this._cors,
|
|
453
|
-
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.EMPTY_OR_RANGE_OR_ENUM_PARAMETER, responses)
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
else if (err instanceof SyntaxError) {
|
|
457
|
-
const result = JSON.stringify({
|
|
458
|
-
"code": "JSON_PARSE",
|
|
459
|
-
"message": (0, cleanSendedError_1.default)(err)
|
|
460
|
-
});
|
|
461
|
-
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
462
|
-
return (0, send_1.default)(req, res, serverCodes_1.default.JSON_PARSE, result, {
|
|
463
|
-
"apiVersion": apiVersion,
|
|
464
|
-
"cors": this._cors,
|
|
465
|
-
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.JSON_PARSE, responses)
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
else if (err instanceof UnauthorizedError_1.default) {
|
|
469
|
-
const result = JSON.stringify({
|
|
470
|
-
"code": "UNAUTHORIZED",
|
|
471
|
-
"message": (0, cleanSendedError_1.default)(err)
|
|
472
|
-
});
|
|
473
|
-
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
474
|
-
return (0, send_1.default)(req, res, serverCodes_1.default.UNAUTHORIZED, result, {
|
|
475
|
-
"apiVersion": apiVersion,
|
|
476
|
-
"cors": this._cors,
|
|
477
|
-
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.UNAUTHORIZED, responses)
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
else if (err instanceof NotFoundError_1.default) {
|
|
481
|
-
const result = JSON.stringify({
|
|
482
|
-
"code": "NOT_FOUND",
|
|
483
|
-
"message": (0, cleanSendedError_1.default)(err)
|
|
484
|
-
});
|
|
485
|
-
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
486
|
-
return (0, send_1.default)(req, res, serverCodes_1.default.NOT_FOUND, result, {
|
|
487
|
-
"apiVersion": apiVersion,
|
|
488
|
-
"cors": this._cors,
|
|
489
|
-
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.NOT_FOUND, responses)
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
else if (err instanceof LockedError_1.default) {
|
|
493
|
-
const result = JSON.stringify({
|
|
494
|
-
"code": "LOCKED",
|
|
495
|
-
"message": (0, cleanSendedError_1.default)(err)
|
|
496
|
-
});
|
|
497
|
-
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
498
|
-
return (0, send_1.default)(req, res, serverCodes_1.default.LOCKED, result, {
|
|
499
|
-
"apiVersion": apiVersion,
|
|
500
|
-
"cors": this._cors,
|
|
501
|
-
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.LOCKED, responses)
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
else {
|
|
505
|
-
this._log("error", err);
|
|
506
|
-
const result = JSON.stringify({
|
|
507
|
-
"code": "INTERNAL_SERVER_ERROR",
|
|
508
|
-
"message": (0, cleanSendedError_1.default)(err)
|
|
509
|
-
});
|
|
510
|
-
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
511
|
-
return (0, send_1.default)(req, res, serverCodes_1.default.INTERNAL_SERVER_ERROR, result, {
|
|
512
|
-
"apiVersion": apiVersion,
|
|
513
|
-
"cors": this._cors,
|
|
514
|
-
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.INTERNAL_SERVER_ERROR, responses)
|
|
515
|
-
});
|
|
516
|
-
}
|
|
417
|
+
const formattedError = (0, formateError_1.default)(err);
|
|
418
|
+
const result = JSON.stringify({
|
|
419
|
+
"code": formattedError.code,
|
|
420
|
+
"message": formattedError.message
|
|
421
|
+
});
|
|
422
|
+
if (formattedError.httpCode === serverCodes_1.default.INTERNAL_SERVER_ERROR) {
|
|
423
|
+
this._log("error", err);
|
|
424
|
+
}
|
|
425
|
+
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
426
|
+
return (0, send_1.default)(req, res, formattedError.httpCode, result, {
|
|
427
|
+
"apiVersion": apiVersion,
|
|
428
|
+
"cors": this._cors,
|
|
429
|
+
"mime": (0, extractMime_1.default)(contentType, formattedError.httpCode, responses)
|
|
517
430
|
// still check response for errors
|
|
518
431
|
}).then((response) => {
|
|
519
432
|
return this._checkResponse ? this._Mediator.checkResponse(operationId, response) : Promise.resolve();
|
package/lib/cjs/main.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.LockedError = exports.NotFoundError = exports.UnauthorizedError = exports.Server = exports.Orchestrator = exports.MediatorUser = exports.Mediator = exports.DescriptorUser = exports.checkNonEmptyStringSync = exports.checkNonEmptyString = exports.checkNonEmptyObjectSync = exports.checkNonEmptyObject = exports.checkNonEmptyNumberSync = exports.checkNonEmptyNumber = exports.checkIntegerSync = exports.checkInteger = exports.checkStringSync = exports.checkString = exports.checkObjectSync = exports.checkObject = exports.checkNumberSync = exports.checkNumber = exports.checkFunctionSync = exports.checkFunction = exports.checkExistsSync = exports.checkExists = void 0;
|
|
7
|
+
exports.formateError = exports.LockedError = exports.NotFoundError = exports.UnauthorizedError = exports.Server = exports.Orchestrator = exports.MediatorUser = exports.Mediator = exports.DescriptorUser = exports.checkNonEmptyStringSync = exports.checkNonEmptyString = exports.checkNonEmptyObjectSync = exports.checkNonEmptyObject = exports.checkNonEmptyNumberSync = exports.checkNonEmptyNumber = exports.checkIntegerSync = exports.checkInteger = exports.checkStringSync = exports.checkString = exports.checkObjectSync = exports.checkObject = exports.checkNumberSync = exports.checkNumber = exports.checkFunctionSync = exports.checkFunction = exports.checkExistsSync = exports.checkExists = void 0;
|
|
8
8
|
// undefined
|
|
9
9
|
const checkExists_1 = require("./checkers/ReferenceError/checkExists");
|
|
10
10
|
Object.defineProperty(exports, "checkExists", { enumerable: true, get: function () { return checkExists_1.checkExists; } });
|
|
@@ -53,3 +53,5 @@ const NotFoundError_1 = __importDefault(require("./components/errors/NotFoundErr
|
|
|
53
53
|
exports.NotFoundError = NotFoundError_1.default;
|
|
54
54
|
const LockedError_1 = __importDefault(require("./components/errors/LockedError"));
|
|
55
55
|
exports.LockedError = LockedError_1.default;
|
|
56
|
+
const formateError_1 = __importDefault(require("./utils/server/formateError"));
|
|
57
|
+
exports.formateError = formateError_1.default;
|
package/lib/cjs/main.d.cts
CHANGED
|
@@ -16,5 +16,6 @@ import Server, { type iClient } from "./components/Server";
|
|
|
16
16
|
import UnauthorizedError from "./components/errors/UnauthorizedError";
|
|
17
17
|
import NotFoundError from "./components/errors/NotFoundError";
|
|
18
18
|
import LockedError from "./components/errors/LockedError";
|
|
19
|
+
import formateError, { type iFormattedError } from "./utils/server/formateError";
|
|
19
20
|
export type { tLogType, tLogger, iEventsMinimal, iUrlAllowedParameters, iClient };
|
|
20
|
-
export { DescriptorUser, type iDescriptorUserOptions, Mediator, MediatorUser, type iMediatorUserOptions, Orchestrator, type iOrchestratorOptions, Server, UnauthorizedError, NotFoundError, LockedError };
|
|
21
|
+
export { DescriptorUser, type iDescriptorUserOptions, Mediator, MediatorUser, type iMediatorUserOptions, Orchestrator, type iOrchestratorOptions, Server, UnauthorizedError, NotFoundError, LockedError, formateError, type iFormattedError };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// deps
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.default = formateError;
|
|
8
|
+
// locals
|
|
9
|
+
const LockedError_1 = __importDefault(require("../../components/errors/LockedError"));
|
|
10
|
+
const NotFoundError_1 = __importDefault(require("../../components/errors/NotFoundError"));
|
|
11
|
+
const UnauthorizedError_1 = __importDefault(require("../../components/errors/UnauthorizedError"));
|
|
12
|
+
const cleanSendedError_1 = __importDefault(require("../cleanSendedError"));
|
|
13
|
+
const serverCodes_1 = __importDefault(require("../serverCodes"));
|
|
14
|
+
// module
|
|
15
|
+
function formateError(err) {
|
|
16
|
+
if (err instanceof ReferenceError) {
|
|
17
|
+
return {
|
|
18
|
+
"httpCode": serverCodes_1.default.MISSING_PARAMETER,
|
|
19
|
+
"code": "MISSING_PARAMETER",
|
|
20
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else if (err instanceof TypeError) {
|
|
24
|
+
return {
|
|
25
|
+
"httpCode": serverCodes_1.default.WRONG_TYPE_PARAMETER,
|
|
26
|
+
"code": "WRONG_TYPE_PARAMETER",
|
|
27
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else if (err instanceof RangeError) {
|
|
31
|
+
return {
|
|
32
|
+
"httpCode": serverCodes_1.default.EMPTY_OR_RANGE_OR_ENUM_PARAMETER,
|
|
33
|
+
"code": "EMPTY_OR_RANGE_OR_ENUM_PARAMETER",
|
|
34
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
else if (err instanceof SyntaxError) {
|
|
38
|
+
return {
|
|
39
|
+
"httpCode": serverCodes_1.default.JSON_PARSE,
|
|
40
|
+
"code": "JSON_PARSE",
|
|
41
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else if (err instanceof UnauthorizedError_1.default) {
|
|
45
|
+
return {
|
|
46
|
+
"httpCode": serverCodes_1.default.UNAUTHORIZED,
|
|
47
|
+
"code": "UNAUTHORIZED",
|
|
48
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
else if (err instanceof NotFoundError_1.default) {
|
|
52
|
+
return {
|
|
53
|
+
"httpCode": serverCodes_1.default.NOT_FOUND,
|
|
54
|
+
"code": "NOT_FOUND",
|
|
55
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
else if (err instanceof LockedError_1.default) {
|
|
59
|
+
return {
|
|
60
|
+
"httpCode": serverCodes_1.default.LOCKED,
|
|
61
|
+
"code": "LOCKED",
|
|
62
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
"httpCode": serverCodes_1.default.INTERNAL_SERVER_ERROR,
|
|
67
|
+
"code": "INTERNAL_SERVER_ERROR",
|
|
68
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
69
|
+
};
|
|
70
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "node-pluginsmanager-plugin",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.3.0",
|
|
5
5
|
"description": "An abstract parent plugin for node-pluginsmanager.",
|
|
6
6
|
|
|
7
7
|
"type": "commonjs",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@types/socket.io": "3.0.2",
|
|
59
59
|
"@types/uniqid": "5.3.4",
|
|
60
60
|
"@types/ws": "8.18.1",
|
|
61
|
-
"check-node-engine": "1.
|
|
61
|
+
"check-node-engine": "1.1.0",
|
|
62
62
|
"check-version-modules": "2.5.0",
|
|
63
63
|
"colors": "1.4.0",
|
|
64
64
|
"eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"socket.io": "4.8.3",
|
|
72
72
|
"socket.io-client": "4.8.3",
|
|
73
73
|
"typescript": "5.9.3",
|
|
74
|
-
"used-deps-analyzer": "0.
|
|
74
|
+
"used-deps-analyzer": "0.4.0",
|
|
75
75
|
"ws": "8.21.0"
|
|
76
76
|
},
|
|
77
77
|
|