@xfilecom/core-sdk 1.4.1 → 1.4.2
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.
- package/dist/filters/microservice-gateway-exception.filter.d.ts +4 -0
- package/dist/filters/microservice-gateway-exception.filter.js +64 -0
- package/dist/filters/microservice-gateway-exception.filter.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MicroserviceGatewayExceptionFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const GATEWAY_UNAVAILABLE_PATTERNS = [
|
|
12
|
+
'ECONNREFUSED',
|
|
13
|
+
'ENOTFOUND',
|
|
14
|
+
'ETIMEDOUT',
|
|
15
|
+
'ECONNRESET',
|
|
16
|
+
'EHOSTUNREACH',
|
|
17
|
+
];
|
|
18
|
+
function isGatewayUnavailableError(message) {
|
|
19
|
+
const upper = message.toUpperCase();
|
|
20
|
+
return GATEWAY_UNAVAILABLE_PATTERNS.some((p) => upper.includes(p));
|
|
21
|
+
}
|
|
22
|
+
function isStandardErrorShape(obj) {
|
|
23
|
+
return (obj != null &&
|
|
24
|
+
typeof obj === 'object' &&
|
|
25
|
+
'code' in obj &&
|
|
26
|
+
'error' in obj &&
|
|
27
|
+
typeof obj.code === 'number');
|
|
28
|
+
}
|
|
29
|
+
let MicroserviceGatewayExceptionFilter = class MicroserviceGatewayExceptionFilter {
|
|
30
|
+
catch(exception, host) {
|
|
31
|
+
const ctx = host.switchToHttp();
|
|
32
|
+
const response = ctx.getResponse();
|
|
33
|
+
if (response.headersSent) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (exception && typeof exception === 'object' && isStandardErrorShape(exception)) {
|
|
37
|
+
const body = {
|
|
38
|
+
code: exception.code,
|
|
39
|
+
data: 'data' in exception && Array.isArray(exception.data) ? exception.data : [],
|
|
40
|
+
error: exception.error,
|
|
41
|
+
};
|
|
42
|
+
response.status(200).json(body);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (exception instanceof Error && isGatewayUnavailableError(exception.message)) {
|
|
46
|
+
response.status(503).json({
|
|
47
|
+
code: 503,
|
|
48
|
+
data: [],
|
|
49
|
+
error: { message: 'Service temporarily unavailable' },
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
response.status(500).json({
|
|
54
|
+
code: 500,
|
|
55
|
+
data: [],
|
|
56
|
+
error: { message: 'Internal server error' },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
exports.MicroserviceGatewayExceptionFilter = MicroserviceGatewayExceptionFilter;
|
|
61
|
+
exports.MicroserviceGatewayExceptionFilter = MicroserviceGatewayExceptionFilter = __decorate([
|
|
62
|
+
(0, common_1.Catch)()
|
|
63
|
+
], MicroserviceGatewayExceptionFilter);
|
|
64
|
+
//# sourceMappingURL=microservice-gateway-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"microservice-gateway-exception.filter.js","sourceRoot":"","sources":["../../src/filters/microservice-gateway-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAu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QACT,CAAC;QAGD,IAAI,SAAS,YAAY,KAAK,IAAI,yBAAyB,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/E,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACxB,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,EAAE;gBACR,KAAK,EAAE,EAAE,OAAO,EAAE,iCAAiC,EAAE;aACtD,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAGD,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACxB,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AArCY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,cAAK,GAAE;GACK,kCAAkC,CAqC9C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './guards/jwt-auth.guard';
|
|
|
18
18
|
export * from './guards/roles.guard';
|
|
19
19
|
export { AllExceptionsFilter, ExceptionFilterOptions } from './filters/exception.filter';
|
|
20
20
|
export { I18nExceptionFilter, type I18nMessageShape, } from './filters/i18n-exception.filter';
|
|
21
|
+
export { MicroserviceGatewayExceptionFilter } from './filters/microservice-gateway-exception.filter';
|
|
21
22
|
export * from './decorators/public.decorator';
|
|
22
23
|
export { User, JwtUser } from './decorators/user.decorator';
|
|
23
24
|
export { Roles, ROLES_KEY } from './decorators/roles.decorator';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.findUserByLookupHash = exports.getEncryptionKey = exports.getOptionalSecret = exports.compareLookupHash = exports.lookupHash = exports.compareByKey = exports.hashByKey = exports.getProfileConfig = exports.BUILT_IN_NORMALIZERS = exports.digitsNormalizer = exports.emailNormalizer = exports.compareEmail = exports.hashEmail = exports.compareValue = exports.hashValue = exports.PBKDF2_SALT_BYTES = exports.PBKDF2_DEFAULT_DIGEST = exports.PBKDF2_DEFAULT_KEYLEN = exports.PBKDF2_DEFAULT_ITERATIONS = exports.deriveKeySha256 = exports.pbkdf2VerifyPassword = exports.pbkdf2HashPassword = exports.DEFAULT_CONFIG_ROOT_CANDIDATES = exports.createConfigLoader = exports.resolveConfigRootDir = exports.CONFIG_SOURCE_ENV_KEY = exports.ENV_CONFIG_FILENAME_PATTERN = exports.DEFAULT_CONFIG_FILENAMES = exports.loadApplicationYamlSync = exports.loadApplicationYaml = exports.getLoggingConfigFromEnv = exports.isProd = exports.isDev = exports.currentAppEnv = exports.isStaging = exports.isProduction = exports.isDevelopment = exports.getAppEnv = exports.ROLES_KEY = exports.Roles = exports.User = exports.MicroserviceGatewayExceptionFilter = exports.I18nExceptionFilter = exports.AllExceptionsFilter = exports.isLevelEnabled = exports.LOG_LEVEL_ORDER = exports.FileLogWriter = exports.ConsoleLogWriter = exports.CommonErrorDto = exports.CommonResponseDto = void 0;
|
|
18
|
+
exports.authenticateWithHashLookup = void 0;
|
|
18
19
|
__exportStar(require("./core.module"), exports);
|
|
19
20
|
__exportStar(require("./database/database.module"), exports);
|
|
20
21
|
__exportStar(require("./database/database.service"), exports);
|
|
@@ -42,6 +43,8 @@ var exception_filter_1 = require("./filters/exception.filter");
|
|
|
42
43
|
Object.defineProperty(exports, "AllExceptionsFilter", { enumerable: true, get: function () { return exception_filter_1.AllExceptionsFilter; } });
|
|
43
44
|
var i18n_exception_filter_1 = require("./filters/i18n-exception.filter");
|
|
44
45
|
Object.defineProperty(exports, "I18nExceptionFilter", { enumerable: true, get: function () { return i18n_exception_filter_1.I18nExceptionFilter; } });
|
|
46
|
+
var microservice_gateway_exception_filter_1 = require("./filters/microservice-gateway-exception.filter");
|
|
47
|
+
Object.defineProperty(exports, "MicroserviceGatewayExceptionFilter", { enumerable: true, get: function () { return microservice_gateway_exception_filter_1.MicroserviceGatewayExceptionFilter; } });
|
|
45
48
|
__exportStar(require("./decorators/public.decorator"), exports);
|
|
46
49
|
var user_decorator_1 = require("./decorators/user.decorator");
|
|
47
50
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_decorator_1.User; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,gDAA8B;AAG9B,6DAA2C;AAC3C,8DAA4C;AAC5C,4DAA0C;AAG1C,6DAA2C;AAC3C,iEAKoC;AAJlC,uHAAA,iBAAiB,OAAA;AACjB,oHAAA,cAAc,OAAA;AAIhB,0DAAwC;AACxC,sDAAoC;AACpC,uDAAqC;AACrC,yDAAuC;AACvC,yDAQgC;AAN9B,kHAAA,gBAAgB,OAAA;AAChB,+GAAA,aAAa,OAAA;AAGb,iHAAA,eAAe,OAAA;AACf,gHAAA,cAAc,OAAA;AAIhB,qEAAmD;AAEnD,4EAA0D;AAC1D,gFAA8D;AAC9D,4EAA0D;AAG1D,0DAAwC;AACxC,uDAAqC;AAGrC,+DAAyF;AAAhF,uHAAA,mBAAmB,OAAA;AAC5B,yEAGyC;AAFvC,4HAAA,mBAAmB,OAAA;AAGrB,yGAAqG;AAA5F,2JAAA,kCAAkC,OAAA;AAG3C,gEAA8C;AAC9C,8DAA4D;AAAnD,sGAAA,IAAI,OAAA;AACb,gEAAgE;AAAvD,wGAAA,KAAK,OAAA;AAAE,4GAAA,SAAS,OAAA;AAGzB,2DAAyC;AAGzC,+CAS2B;AARzB,sGAAA,SAAS,OA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