@nathapp/nestjs-common 2.1.4 → 3.0.0-rc.4
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/CLAUDE.md +29 -0
- package/README.md +134 -0
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js.map +1 -1
- package/dist/config/server-security.config.d.ts +1 -0
- package/dist/config/server-security.config.js +19 -2
- package/dist/config/server-security.config.js.map +1 -1
- package/dist/decorator/index.d.ts +2 -2
- package/dist/decorator/index.js.map +1 -1
- package/dist/entities/base-entity.d.ts +3 -0
- package/dist/entities/base-entity.js +8 -0
- package/dist/entities/base-entity.js.map +1 -0
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.js +18 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/exception/app.exception.d.ts +4 -3
- package/dist/exception/app.exception.js +1 -1
- package/dist/exception/app.exception.js.map +1 -1
- package/dist/exception/default-i18n-validation-exception.filter.js +1 -1
- package/dist/exception/default-i18n-validation-exception.filter.js.map +1 -1
- package/dist/exception/exception.constants.d.ts +1 -0
- package/dist/exception/exception.constants.js +5 -0
- package/dist/exception/exception.constants.js.map +1 -0
- package/dist/exception/exception.module.d.ts +7 -0
- package/dist/exception/exception.module.js +41 -0
- package/dist/exception/exception.module.js.map +1 -0
- package/dist/exception/exceptions/auth.exception.d.ts +4 -0
- package/dist/exception/exceptions/auth.exception.js +12 -0
- package/dist/exception/exceptions/auth.exception.js.map +1 -0
- package/dist/exception/exceptions/forbidden-app.exception.d.ts +4 -0
- package/dist/exception/exceptions/forbidden-app.exception.js +12 -0
- package/dist/exception/exceptions/forbidden-app.exception.js.map +1 -0
- package/dist/exception/exceptions/index.d.ts +6 -0
- package/dist/exception/exceptions/index.js +16 -0
- package/dist/exception/exceptions/index.js.map +1 -0
- package/dist/exception/exceptions/internal-app.exception.d.ts +4 -0
- package/dist/exception/exceptions/internal-app.exception.js +12 -0
- package/dist/exception/exceptions/internal-app.exception.js.map +1 -0
- package/dist/exception/exceptions/not-found-app.exception.d.ts +4 -0
- package/dist/exception/exceptions/not-found-app.exception.js +12 -0
- package/dist/exception/exceptions/not-found-app.exception.js.map +1 -0
- package/dist/exception/exceptions/throttle-app.exception.d.ts +4 -0
- package/dist/exception/exceptions/throttle-app.exception.js +12 -0
- package/dist/exception/exceptions/throttle-app.exception.js.map +1 -0
- package/dist/exception/exceptions/validation-app.exception.d.ts +4 -0
- package/dist/exception/exceptions/validation-app.exception.js +12 -0
- package/dist/exception/exceptions/validation-app.exception.js.map +1 -0
- package/dist/exception/global-exception.filter.d.ts +8 -54
- package/dist/exception/global-exception.filter.js +45 -163
- package/dist/exception/global-exception.filter.js.map +1 -1
- package/dist/exception/handler/app-exception.handler.d.ts +7 -0
- package/dist/exception/handler/app-exception.handler.js +44 -0
- package/dist/exception/handler/app-exception.handler.js.map +1 -0
- package/dist/exception/handler/bad-request.handler.d.ts +6 -0
- package/dist/exception/handler/bad-request.handler.js +30 -0
- package/dist/exception/handler/bad-request.handler.js.map +1 -0
- package/dist/exception/handler/exception-handler.interface.d.ts +14 -0
- package/dist/exception/handler/exception-handler.interface.js +3 -0
- package/dist/exception/handler/exception-handler.interface.js.map +1 -0
- package/dist/exception/handler/forbidden.handler.d.ts +6 -0
- package/dist/exception/handler/forbidden.handler.js +27 -0
- package/dist/exception/handler/forbidden.handler.js.map +1 -0
- package/dist/exception/handler/index.d.ts +11 -0
- package/dist/exception/handler/index.js +38 -0
- package/dist/exception/handler/index.js.map +1 -0
- package/dist/exception/handler/microservice.handler.d.ts +6 -0
- package/dist/exception/handler/microservice.handler.js +27 -0
- package/dist/exception/handler/microservice.handler.js.map +1 -0
- package/dist/exception/handler/not-found.handler.d.ts +6 -0
- package/dist/exception/handler/not-found.handler.js +27 -0
- package/dist/exception/handler/not-found.handler.js.map +1 -0
- package/dist/exception/handler/throttler.handler.d.ts +6 -0
- package/dist/exception/handler/throttler.handler.js +33 -0
- package/dist/exception/handler/throttler.handler.js.map +1 -0
- package/dist/exception/handler/unknown.handler.d.ts +6 -0
- package/dist/exception/handler/unknown.handler.js +35 -0
- package/dist/exception/handler/unknown.handler.js.map +1 -0
- package/dist/exception/handler/username-not-found.handler.d.ts +6 -0
- package/dist/exception/handler/username-not-found.handler.js +28 -0
- package/dist/exception/handler/username-not-found.handler.js.map +1 -0
- package/dist/exception/index.d.ts +7 -4
- package/dist/exception/index.js +12 -3
- package/dist/exception/index.js.map +1 -1
- package/dist/exception/micro-service.exception.js +1 -1
- package/dist/exception/micro-service.exception.js.map +1 -1
- package/dist/exception/user-not-found.exception.js +1 -1
- package/dist/http/index.d.ts +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptor/serializable.interceptor.d.ts +4 -2
- package/dist/interceptor/serializable.interceptor.js +75 -18
- package/dist/interceptor/serializable.interceptor.js.map +1 -1
- package/dist/ip/index.d.ts +3 -2
- package/dist/ip/index.js +4 -1
- package/dist/ip/index.js.map +1 -1
- package/dist/ip/request-ip.d.ts +4 -2
- package/dist/ip/request-ip.js +92 -30
- package/dist/ip/request-ip.js.map +1 -1
- package/dist/ip/trusted-proxy-presets.d.ts +3 -0
- package/dist/ip/trusted-proxy-presets.js +114 -0
- package/dist/ip/trusted-proxy-presets.js.map +1 -0
- package/dist/module/configurable-module.builder.js +3 -1
- package/dist/module/configurable-module.builder.js.map +1 -1
- package/dist/module/index.d.ts +5 -5
- package/dist/module/index.js.map +1 -1
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +18 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pagination/page.d.ts +39 -0
- package/dist/pagination/page.js +87 -0
- package/dist/pagination/page.js.map +1 -0
- package/dist/serialize/localize.string.js.map +1 -1
- package/dist/utils/package-utils.js +3 -0
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/validators.d.ts +3 -0
- package/dist/validation/validators.js +29 -0
- package/dist/validation/validators.js.map +1 -0
- package/docs/20260214-coverage-plan.md +52 -0
- package/docs/20260214-fix-plan-common-bugs.md +90 -0
- package/docs/20260214-fix-plan-common-cleanup.md +119 -0
- package/docs/20260214-fix-plan-exception-redesign.md +274 -0
- package/docs/20260214-fix-plan-nestjs-prisma.md +454 -0
- package/docs/20260214-fix-plan-pagination-move-and-rename.md +148 -0
- package/docs/20260214-review-common.md +426 -0
- package/docs/20260215-fix-plan-review-enhancements.md +110 -0
- package/docs/20260215-fix-plan-trust-proxy-presets.md +227 -0
- package/docs/20260215-review-nestjs-common.md +1015 -0
- package/docs/trust-proxy-security.md +475 -0
- package/package.json +1 -1
- package/dist/exception/app-exception.filter.d.ts +0 -9
- package/dist/exception/app-exception.filter.js +0 -52
- package/dist/exception/app-exception.filter.js.map +0 -1
- package/dist/i18n/i18n.constants.d.ts +0 -0
- package/dist/i18n/i18n.constants.js +0 -1
- package/dist/i18n/i18n.constants.js.map +0 -1
- package/dist/middleware/index.d.ts +0 -4
- package/dist/middleware/index.js +0 -14
- package/dist/middleware/index.js.map +0 -1
- package/dist/middleware/log.provider.d.ts +0 -38
- package/dist/middleware/log.provider.js +0 -147
- package/dist/middleware/log.provider.js.map +0 -1
- package/dist/middleware/logger-option.factory.d.ts +0 -17
- package/dist/middleware/logger-option.factory.js +0 -73
- package/dist/middleware/logger-option.factory.js.map +0 -1
- package/dist/middleware/logger.middleware.d.ts +0 -8
- package/dist/middleware/logger.middleware.js +0 -97
- package/dist/middleware/logger.middleware.js.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotFoundExceptionHandler = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const app_exception_code_enum_1 = require("../app-exception-code.enum");
|
|
6
|
+
class NotFoundExceptionHandler {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.logger = new common_1.Logger(NotFoundExceptionHandler.name);
|
|
9
|
+
}
|
|
10
|
+
canHandle(exception) {
|
|
11
|
+
return exception instanceof common_1.NotFoundException;
|
|
12
|
+
}
|
|
13
|
+
handle(exception, context) {
|
|
14
|
+
const notFoundException = exception;
|
|
15
|
+
const httpStatus = notFoundException.getStatus();
|
|
16
|
+
const errorCode = app_exception_code_enum_1.CommonExceptionCode.NOT_FOUND;
|
|
17
|
+
const message = notFoundException.message;
|
|
18
|
+
this.logger.warn(`Method: ${context.request.method}, url: ${context.request.url}`, notFoundException.name);
|
|
19
|
+
return {
|
|
20
|
+
httpStatus,
|
|
21
|
+
errorCode,
|
|
22
|
+
message,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.NotFoundExceptionHandler = NotFoundExceptionHandler;
|
|
27
|
+
//# sourceMappingURL=not-found.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-found.handler.js","sourceRoot":"","sources":["../../../lib/exception/handler/not-found.handler.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAC3D,wEAAiE;AAGjE,MAAa,wBAAwB;IAArC;QACmB,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAuBtE,CAAC;IArBC,SAAS,CAAC,SAAkB;QAC1B,OAAO,SAAS,YAAY,0BAAiB,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,SAAkB,EAAE,OAAyB;QAClD,MAAM,iBAAiB,GAAG,SAA8B,CAAC;QACzD,MAAM,UAAU,GAAG,iBAAiB,CAAC,SAAS,EAAE,CAAC;QACjD,MAAM,SAAS,GAAG,6CAAmB,CAAC,SAAS,CAAC;QAChD,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;QAE1C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,WAAW,OAAO,CAAC,OAAO,CAAC,MAAM,UAAU,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAChE,iBAAiB,CAAC,IAAI,CACvB,CAAC;QAEF,OAAO;YACL,UAAU;YACV,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AAxBD,4DAwBC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExceptionContext, ExceptionHandler, ExceptionResult } from "./exception-handler.interface";
|
|
2
|
+
export declare class ThrottlerExceptionHandler implements ExceptionHandler {
|
|
3
|
+
private readonly logger;
|
|
4
|
+
canHandle(exception: unknown): boolean;
|
|
5
|
+
handle(exception: unknown, context: ExceptionContext): Promise<ExceptionResult>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThrottlerExceptionHandler = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const app_exception_code_enum_1 = require("../app-exception-code.enum");
|
|
6
|
+
class ThrottlerExceptionHandler {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.logger = new common_1.Logger(ThrottlerExceptionHandler.name);
|
|
9
|
+
}
|
|
10
|
+
canHandle(exception) {
|
|
11
|
+
var _a;
|
|
12
|
+
if (!exception)
|
|
13
|
+
return false;
|
|
14
|
+
if (typeof exception !== 'object')
|
|
15
|
+
return false;
|
|
16
|
+
const ex = exception;
|
|
17
|
+
return ((_a = ex.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'ThrottlerException'
|
|
18
|
+
|| (ex.message === 'ThrottlerException: Too Many Requests' && ex.status === 429);
|
|
19
|
+
}
|
|
20
|
+
async handle(exception, context) {
|
|
21
|
+
const httpStatus = 429;
|
|
22
|
+
const errorCode = app_exception_code_enum_1.CommonExceptionCode.TOO_MANY_REQUESTS;
|
|
23
|
+
const message = await context.translate(errorCode, context.lang);
|
|
24
|
+
this.logger.debug(`ThrottlerException: ${message}`);
|
|
25
|
+
return {
|
|
26
|
+
httpStatus,
|
|
27
|
+
errorCode,
|
|
28
|
+
message,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ThrottlerExceptionHandler = ThrottlerExceptionHandler;
|
|
33
|
+
//# sourceMappingURL=throttler.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttler.handler.js","sourceRoot":"","sources":["../../../lib/exception/handler/throttler.handler.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,wEAAiE;AAGjE,MAAa,yBAAyB;IAAtC;QACmB,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAwBvE,CAAC;IAtBC,SAAS,CAAC,SAAkB;;QAC1B,IAAI,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7B,IAAI,OAAO,SAAS,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAChD,MAAM,EAAE,GAAG,SAAgB,CAAC;QAE5B,OAAO,CAAA,MAAA,EAAE,CAAC,WAAW,0CAAE,IAAI,MAAK,oBAAoB;eAC/C,CAAC,EAAE,CAAC,OAAO,KAAK,uCAAuC,IAAI,EAAE,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;IACrF,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAkB,EAAE,OAAyB;QACxD,MAAM,UAAU,GAAG,GAAG,CAAC;QACvB,MAAM,SAAS,GAAG,6CAAmB,CAAC,iBAAiB,CAAC;QACxD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAEjE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAC;QAEpD,OAAO;YACL,UAAU;YACV,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AAzBD,8DAyBC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExceptionContext, ExceptionHandler, ExceptionResult } from "./exception-handler.interface";
|
|
2
|
+
export declare class UnknownExceptionHandler implements ExceptionHandler {
|
|
3
|
+
private readonly logger;
|
|
4
|
+
canHandle(exception: unknown): boolean;
|
|
5
|
+
handle(exception: unknown, context: ExceptionContext): Promise<ExceptionResult>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownExceptionHandler = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const common_2 = require("@nathapp/common");
|
|
6
|
+
const app_exception_code_enum_1 = require("../app-exception-code.enum");
|
|
7
|
+
class UnknownExceptionHandler {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.logger = new common_1.Logger(UnknownExceptionHandler.name);
|
|
10
|
+
}
|
|
11
|
+
canHandle(exception) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
async handle(exception, context) {
|
|
15
|
+
const httpStatus = exception instanceof common_1.HttpException
|
|
16
|
+
? exception.getStatus()
|
|
17
|
+
: common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
18
|
+
const errorCode = app_exception_code_enum_1.CommonExceptionCode.UNKNOWN_ERROR;
|
|
19
|
+
const { message: errorMessage } = (0, common_2.describeError)(exception);
|
|
20
|
+
const responseBody = {
|
|
21
|
+
statusCode: httpStatus,
|
|
22
|
+
timestamp: new Date().toISOString(),
|
|
23
|
+
path: context.request.url,
|
|
24
|
+
};
|
|
25
|
+
this.logger.error(`Unknown Error occur. msg: ${errorMessage}, data: ${JSON.stringify(responseBody)}`, exception instanceof Error ? exception.stack : undefined);
|
|
26
|
+
const message = await context.translate(errorCode, context.lang);
|
|
27
|
+
return {
|
|
28
|
+
httpStatus,
|
|
29
|
+
errorCode,
|
|
30
|
+
message,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.UnknownExceptionHandler = UnknownExceptionHandler;
|
|
35
|
+
//# sourceMappingURL=unknown.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknown.handler.js","sourceRoot":"","sources":["../../../lib/exception/handler/unknown.handler.ts"],"names":[],"mappings":";;;AAAA,2CAAmE;AACnE,4CAAgD;AAChD,wEAAiE;AAGjE,MAAa,uBAAuB;IAApC;QACmB,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAkCrE,CAAC;IAhCC,SAAS,CAAC,SAAkB;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAkB,EAAE,OAAyB;QACxD,MAAM,UAAU,GACd,SAAS,YAAY,sBAAa;YAChC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE;YACvB,CAAC,CAAC,mBAAU,CAAC,qBAAqB,CAAC;QAEvC,MAAM,SAAS,GAAG,6CAAmB,CAAC,aAAa,CAAC;QACpD,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAA,sBAAa,EAAC,SAAS,CAAC,CAAC;QAE3D,MAAM,YAAY,GAAG;YACnB,UAAU,EAAE,UAAU;YACtB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG;SAC1B,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,6BAA6B,YAAY,WAAW,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,EAClF,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CACzD,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAEjE,OAAO;YACL,UAAU;YACV,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AAnCD,0DAmCC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExceptionContext, ExceptionHandler, ExceptionResult } from "./exception-handler.interface";
|
|
2
|
+
export declare class UsernameNotFoundExceptionHandler implements ExceptionHandler {
|
|
3
|
+
private readonly logger;
|
|
4
|
+
canHandle(exception: unknown): boolean;
|
|
5
|
+
handle(exception: unknown, context: ExceptionContext): Promise<ExceptionResult>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsernameNotFoundExceptionHandler = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const app_exception_code_enum_1 = require("../app-exception-code.enum");
|
|
6
|
+
const user_not_found_exception_1 = require("../user-not-found.exception");
|
|
7
|
+
class UsernameNotFoundExceptionHandler {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.logger = new common_1.Logger(UsernameNotFoundExceptionHandler.name);
|
|
10
|
+
}
|
|
11
|
+
canHandle(exception) {
|
|
12
|
+
return exception instanceof user_not_found_exception_1.UsernameNotFoundException;
|
|
13
|
+
}
|
|
14
|
+
async handle(exception, context) {
|
|
15
|
+
const usernameNotFoundException = exception;
|
|
16
|
+
const httpStatus = 404;
|
|
17
|
+
const errorCode = app_exception_code_enum_1.CommonExceptionCode.USER_NOT_FOUND;
|
|
18
|
+
const message = await context.translate(errorCode, context.lang);
|
|
19
|
+
this.logger.warn(usernameNotFoundException.message, user_not_found_exception_1.UsernameNotFoundException.name);
|
|
20
|
+
return {
|
|
21
|
+
httpStatus,
|
|
22
|
+
errorCode,
|
|
23
|
+
message,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.UsernameNotFoundExceptionHandler = UsernameNotFoundExceptionHandler;
|
|
28
|
+
//# sourceMappingURL=username-not-found.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"username-not-found.handler.js","sourceRoot":"","sources":["../../../lib/exception/handler/username-not-found.handler.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,wEAAiE;AACjE,0EAAwE;AAGxE,MAAa,gCAAgC;IAA7C;QACmB,WAAM,GAAG,IAAI,eAAM,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC;IAoB9E,CAAC;IAlBC,SAAS,CAAC,SAAkB;QAC1B,OAAO,SAAS,YAAY,oDAAyB,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAkB,EAAE,OAAyB;QACxD,MAAM,yBAAyB,GAAG,SAAsC,CAAC;QACzE,MAAM,UAAU,GAAG,GAAG,CAAC;QACvB,MAAM,SAAS,GAAG,6CAAmB,CAAC,cAAc,CAAC;QACrD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAEjE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,oDAAyB,CAAC,IAAI,CAAC,CAAC;QAEpF,OAAO;YACL,UAAU;YACV,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AArBD,4EAqBC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { CommonExceptionCode } from "./app-exception-code.enum";
|
|
2
|
-
import {
|
|
3
|
-
import { AppException } from "./app.exception";
|
|
2
|
+
import { AppException, AppExceptionArgs } from "./app.exception";
|
|
4
3
|
import { CaptchaException } from "./captcha.exception";
|
|
5
4
|
import { DefaultI18nValidationExceptionFilter, defaultResponseFormatter } from "./default-i18n-validation-exception.filter";
|
|
6
5
|
import { GlobalExceptionsFilter } from "./global-exception.filter";
|
|
7
|
-
import { I18nValidationExceptionFilter, I18nValidationExceptionFilterOptions } from "./i18n-validation-exception.filter";
|
|
6
|
+
import { I18nValidationExceptionFilter, type I18nValidationExceptionFilterOptions } from "./i18n-validation-exception.filter";
|
|
8
7
|
import { HttpMicroServiceException } from "./micro-service.exception";
|
|
9
8
|
import { TwoFactorInvalidException, TwoFactorRequiredException } from "./two-factor.exception";
|
|
10
9
|
import { UsernameNotFoundException } from "./user-not-found.exception";
|
|
11
|
-
|
|
10
|
+
import { AuthException, ForbiddenAppException, NotFoundAppException, ValidationAppException, ThrottleAppException, InternalAppException } from "./exceptions";
|
|
11
|
+
import { ExceptionModule } from "./exception.module";
|
|
12
|
+
import { EXCEPTION_HANDLERS } from "./exception.constants";
|
|
13
|
+
export { AppException, AppExceptionArgs, GlobalExceptionsFilter, UsernameNotFoundException, CommonExceptionCode, HttpMicroServiceException, defaultResponseFormatter, DefaultI18nValidationExceptionFilter, type I18nValidationExceptionFilterOptions, I18nValidationExceptionFilter, CaptchaException, TwoFactorRequiredException, TwoFactorInvalidException, AuthException, ForbiddenAppException, NotFoundAppException, ValidationAppException, ThrottleAppException, InternalAppException, ExceptionModule, EXCEPTION_HANDLERS };
|
|
14
|
+
export type { ExceptionHandler, ExceptionContext, ExceptionResult } from "./handler";
|
package/dist/exception/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TwoFactorInvalidException = exports.TwoFactorRequiredException = exports.CaptchaException = exports.I18nValidationExceptionFilter = exports.DefaultI18nValidationExceptionFilter = exports.defaultResponseFormatter = exports.HttpMicroServiceException = exports.CommonExceptionCode = exports.UsernameNotFoundException = exports.GlobalExceptionsFilter = exports.
|
|
3
|
+
exports.EXCEPTION_HANDLERS = exports.ExceptionModule = exports.InternalAppException = exports.ThrottleAppException = exports.ValidationAppException = exports.NotFoundAppException = exports.ForbiddenAppException = exports.AuthException = exports.TwoFactorInvalidException = exports.TwoFactorRequiredException = exports.CaptchaException = exports.I18nValidationExceptionFilter = exports.DefaultI18nValidationExceptionFilter = exports.defaultResponseFormatter = exports.HttpMicroServiceException = exports.CommonExceptionCode = exports.UsernameNotFoundException = exports.GlobalExceptionsFilter = exports.AppException = void 0;
|
|
4
4
|
const app_exception_code_enum_1 = require("./app-exception-code.enum");
|
|
5
5
|
Object.defineProperty(exports, "CommonExceptionCode", { enumerable: true, get: function () { return app_exception_code_enum_1.CommonExceptionCode; } });
|
|
6
|
-
const app_exception_filter_1 = require("./app-exception.filter");
|
|
7
|
-
Object.defineProperty(exports, "AppExceptionFilter", { enumerable: true, get: function () { return app_exception_filter_1.AppExceptionFilter; } });
|
|
8
6
|
const app_exception_1 = require("./app.exception");
|
|
9
7
|
Object.defineProperty(exports, "AppException", { enumerable: true, get: function () { return app_exception_1.AppException; } });
|
|
10
8
|
const captcha_exception_1 = require("./captcha.exception");
|
|
@@ -23,4 +21,15 @@ Object.defineProperty(exports, "TwoFactorInvalidException", { enumerable: true,
|
|
|
23
21
|
Object.defineProperty(exports, "TwoFactorRequiredException", { enumerable: true, get: function () { return two_factor_exception_1.TwoFactorRequiredException; } });
|
|
24
22
|
const user_not_found_exception_1 = require("./user-not-found.exception");
|
|
25
23
|
Object.defineProperty(exports, "UsernameNotFoundException", { enumerable: true, get: function () { return user_not_found_exception_1.UsernameNotFoundException; } });
|
|
24
|
+
const exceptions_1 = require("./exceptions");
|
|
25
|
+
Object.defineProperty(exports, "AuthException", { enumerable: true, get: function () { return exceptions_1.AuthException; } });
|
|
26
|
+
Object.defineProperty(exports, "ForbiddenAppException", { enumerable: true, get: function () { return exceptions_1.ForbiddenAppException; } });
|
|
27
|
+
Object.defineProperty(exports, "NotFoundAppException", { enumerable: true, get: function () { return exceptions_1.NotFoundAppException; } });
|
|
28
|
+
Object.defineProperty(exports, "ValidationAppException", { enumerable: true, get: function () { return exceptions_1.ValidationAppException; } });
|
|
29
|
+
Object.defineProperty(exports, "ThrottleAppException", { enumerable: true, get: function () { return exceptions_1.ThrottleAppException; } });
|
|
30
|
+
Object.defineProperty(exports, "InternalAppException", { enumerable: true, get: function () { return exceptions_1.InternalAppException; } });
|
|
31
|
+
const exception_module_1 = require("./exception.module");
|
|
32
|
+
Object.defineProperty(exports, "ExceptionModule", { enumerable: true, get: function () { return exception_module_1.ExceptionModule; } });
|
|
33
|
+
const exception_constants_1 = require("./exception.constants");
|
|
34
|
+
Object.defineProperty(exports, "EXCEPTION_HANDLERS", { enumerable: true, get: function () { return exception_constants_1.EXCEPTION_HANDLERS; } });
|
|
26
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/exception/index.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/exception/index.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAa4B,oGAbnF,6CAAmB,OAamF;AAZ/G,mDAAiE;AAYxD,6FAZA,4BAAY,OAYA;AAXrB,2DAAuD;AAarD,iGAbO,oCAAgB,OAaP;AAZlB,yGAA4H;AAW1H,qHAXO,+EAAoC,OAWP;AADsG,yGAV7F,mEAAwB,OAU6F;AATpK,uEAAmE;AAS1B,uGAThC,gDAAsB,OASgC;AAR/D,yFAA8H;AAS3C,8GAT1E,gEAA6B,OAS0E;AARhH,uEAAsE;AAO2C,0GAPxG,mDAAyB,OAOwG;AAN1I,iEAA+F;AAQ/C,0GARvC,gDAAyB,OAQuC;AAArD,2GARgB,iDAA0B,OAQhB;AAP9C,yEAAuE;AAKN,0GALxD,oDAAyB,OAKwD;AAJ1F,6CAA8J;AAO5J,8FAPO,0BAAa,OAOP;AAAE,sGAPO,kCAAqB,OAOP;AAAE,qGAPO,iCAAoB,OAOP;AAAE,uGAPO,mCAAsB,OAOP;AAAE,qGAPO,iCAAoB,OAOP;AAAE,qGAPO,iCAAoB,OAOP;AANhI,yDAAqD;AAOnD,gGAPO,kCAAe,OAOP;AANjB,+DAA2D;AAMxC,mGANV,wCAAkB,OAMU"}
|
|
@@ -4,7 +4,7 @@ exports.HttpMicroServiceException = void 0;
|
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
class HttpMicroServiceException extends common_1.HttpException {
|
|
6
6
|
constructor(ret, message) {
|
|
7
|
-
super({ ret, message },
|
|
7
|
+
super({ ret, message }, 500);
|
|
8
8
|
this._ret = ret;
|
|
9
9
|
this.message = message;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"micro-service.exception.js","sourceRoot":"","sources":["../../lib/exception/micro-service.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;
|
|
1
|
+
{"version":3,"file":"micro-service.exception.js","sourceRoot":"","sources":["../../lib/exception/micro-service.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAK/C,MAAa,yBAA0B,SAAQ,sBAAa;IAG1D,YAAY,GAAW,EAAE,OAAe;QACtC,KAAK,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF;AAZD,8DAYC"}
|
|
@@ -4,7 +4,7 @@ exports.UsernameNotFoundException = void 0;
|
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
class UsernameNotFoundException extends common_1.HttpException {
|
|
6
6
|
constructor(message) {
|
|
7
|
-
super(message,
|
|
7
|
+
super(message, 404);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
exports.UsernameNotFoundException = UsernameNotFoundException;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Request } from "./request";
|
|
2
|
-
import { Response } from "./response";
|
|
3
|
-
export { Request, Response, };
|
|
1
|
+
import { type Request } from "./request";
|
|
2
|
+
import { type Response } from "./response";
|
|
3
|
+
export { type Request, type Response, };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export * from "./config";
|
|
2
2
|
export * from "./constant";
|
|
3
3
|
export * from "./decorator";
|
|
4
|
+
export * from "./entities";
|
|
4
5
|
export * from "./exception";
|
|
5
6
|
export * from "./http";
|
|
6
7
|
export * from "./i18n";
|
|
7
8
|
export * from "./interceptor";
|
|
8
9
|
export * from "./ip";
|
|
9
10
|
export * from "./logging";
|
|
10
|
-
export * from "./middleware";
|
|
11
11
|
export * from "./module";
|
|
12
|
+
export * from "./pagination";
|
|
12
13
|
export * from "./serialize";
|
|
13
14
|
export * from "./utils";
|
|
14
15
|
export * from "./validation";
|
package/dist/index.js
CHANGED
|
@@ -17,14 +17,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./config"), exports);
|
|
18
18
|
__exportStar(require("./constant"), exports);
|
|
19
19
|
__exportStar(require("./decorator"), exports);
|
|
20
|
+
__exportStar(require("./entities"), exports);
|
|
20
21
|
__exportStar(require("./exception"), exports);
|
|
21
22
|
__exportStar(require("./http"), exports);
|
|
22
23
|
__exportStar(require("./i18n"), exports);
|
|
23
24
|
__exportStar(require("./interceptor"), exports);
|
|
24
25
|
__exportStar(require("./ip"), exports);
|
|
25
26
|
__exportStar(require("./logging"), exports);
|
|
26
|
-
__exportStar(require("./middleware"), exports);
|
|
27
27
|
__exportStar(require("./module"), exports);
|
|
28
|
+
__exportStar(require("./pagination"), exports);
|
|
28
29
|
__exportStar(require("./serialize"), exports);
|
|
29
30
|
__exportStar(require("./utils"), exports);
|
|
30
31
|
__exportStar(require("./validation"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B;AAC3B,8CAA4B;AAC5B,8CAA4B;AAC5B,yCAAuB;AACvB,yCAAuB;AACvB,gDAA8B;AAC9B,uCAAqB;AACrB,4CAA0B;AAC1B,+CAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B;AAC3B,8CAA4B;AAC5B,6CAA2B;AAC3B,8CAA4B;AAC5B,yCAAuB;AACvB,yCAAuB;AACvB,gDAA8B;AAC9B,uCAAqB;AACrB,4CAA0B;AAC1B,2CAAyB;AACzB,+CAA6B;AAC7B,8CAA4B;AAC5B,0CAAwB;AACxB,+CAA6B"}
|
|
@@ -5,14 +5,16 @@ import { LocaleObject, LocaleString } from "../serialize";
|
|
|
5
5
|
export declare class SerializableInterceptor extends ClassSerializerInterceptor {
|
|
6
6
|
protected readonly reflector: any;
|
|
7
7
|
protected readonly defaultOptions: ClassSerializerInterceptorOptions;
|
|
8
|
+
private readonly logger;
|
|
8
9
|
private fallbackLanguage;
|
|
9
10
|
constructor(reflector: any, defaultOptions?: ClassSerializerInterceptorOptions);
|
|
10
11
|
intercept(context: ExecutionContext, next: CallHandler<any>): Observable<any>;
|
|
11
12
|
customSerialize(response: PlainLiteralObject | Array<PlainLiteralObject>, options: ClassTransformOptions, lang: string): PlainLiteralObject | PlainLiteralObject[] | StreamableFile;
|
|
12
13
|
serializeObject(obj: PlainLiteralObject, options: ClassTransformOptions, lang: string): PlainLiteralObject;
|
|
13
|
-
|
|
14
|
+
private deepClone;
|
|
15
|
+
transformObject(obj: PlainLiteralObject, lang: string, depth?: number): PlainLiteralObject;
|
|
14
16
|
transformLocaleString(obj: LocaleString, lang: string): string;
|
|
15
|
-
transformLocaleObject(obj: LocaleObject, lang: string): "" | PlainLiteralObject;
|
|
17
|
+
transformLocaleObject(obj: LocaleObject, lang: string, depth?: number): "" | PlainLiteralObject;
|
|
16
18
|
isObject: (fn: any) => fn is object;
|
|
17
19
|
isNil: (val: any) => val is null | undefined;
|
|
18
20
|
isUndefined: (obj: any) => obj is undefined;
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var SerializableInterceptor_1;
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.SerializableInterceptor = void 0;
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
@@ -18,11 +19,13 @@ const class_transformer_1 = require("class-transformer");
|
|
|
18
19
|
const rxjs_1 = require("rxjs");
|
|
19
20
|
const serialize_1 = require("../serialize");
|
|
20
21
|
const constant_1 = require("../constant");
|
|
21
|
-
|
|
22
|
+
const MAX_DEPTH = 100;
|
|
23
|
+
let SerializableInterceptor = SerializableInterceptor_1 = class SerializableInterceptor extends common_1.ClassSerializerInterceptor {
|
|
22
24
|
constructor(reflector, defaultOptions = {}) {
|
|
23
25
|
super(reflector, defaultOptions);
|
|
24
26
|
this.reflector = reflector;
|
|
25
27
|
this.defaultOptions = defaultOptions;
|
|
28
|
+
this.logger = new common_1.Logger(SerializableInterceptor_1.name);
|
|
26
29
|
this.fallbackLanguage = 'en_US';
|
|
27
30
|
this.isObject = (fn) => !this.isNil(fn) && typeof fn === 'object';
|
|
28
31
|
this.isNil = (val) => this.isUndefined(val) || val === null;
|
|
@@ -45,37 +48,91 @@ let SerializableInterceptor = class SerializableInterceptor extends common_1.Cla
|
|
|
45
48
|
return response;
|
|
46
49
|
}
|
|
47
50
|
return Array.isArray(response)
|
|
48
|
-
? response.map((item) =>
|
|
51
|
+
? response.map((item) => {
|
|
52
|
+
if (!this.isObject(item) || item === null) {
|
|
53
|
+
return item;
|
|
54
|
+
}
|
|
55
|
+
return this.serializeObject(item, options, lang);
|
|
56
|
+
})
|
|
49
57
|
: this.serializeObject(response, options, lang);
|
|
50
58
|
}
|
|
51
59
|
serializeObject(obj, options, lang) {
|
|
52
60
|
const data = obj instanceof serialize_1.Serializable ? (0, class_transformer_1.instanceToInstance)(obj, options) : obj;
|
|
53
|
-
|
|
61
|
+
const cloned = this.deepClone(data);
|
|
62
|
+
return this.transformToPlain(this.transformObject(cloned, lang, 0), options);
|
|
63
|
+
}
|
|
64
|
+
deepClone(obj) {
|
|
65
|
+
if (obj === null || obj === undefined) {
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
if (obj instanceof serialize_1.LocaleString) {
|
|
69
|
+
const cloned = new serialize_1.LocaleString();
|
|
70
|
+
Object.assign(cloned, obj);
|
|
71
|
+
return cloned;
|
|
72
|
+
}
|
|
73
|
+
if (obj instanceof serialize_1.LocaleObject) {
|
|
74
|
+
const cloned = new serialize_1.LocaleObject();
|
|
75
|
+
Object.assign(cloned, obj);
|
|
76
|
+
return cloned;
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(obj)) {
|
|
79
|
+
return obj.map(item => this.deepClone(item));
|
|
80
|
+
}
|
|
81
|
+
if (typeof obj === 'object') {
|
|
82
|
+
const cloned = {};
|
|
83
|
+
for (const key in obj) {
|
|
84
|
+
if (obj.hasOwnProperty(key)) {
|
|
85
|
+
cloned[key] = this.deepClone(obj[key]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return cloned;
|
|
89
|
+
}
|
|
90
|
+
return obj;
|
|
54
91
|
}
|
|
55
|
-
transformObject(obj, lang) {
|
|
92
|
+
transformObject(obj, lang, depth = 0) {
|
|
93
|
+
if (depth > MAX_DEPTH) {
|
|
94
|
+
this.logger.warn(`transformObject exceeded maximum depth of ${MAX_DEPTH}. ` +
|
|
95
|
+
`Returning object as-is to prevent stack overflow. ` +
|
|
96
|
+
`This may indicate a circular reference or excessively nested data structure.`);
|
|
97
|
+
return obj;
|
|
98
|
+
}
|
|
99
|
+
const result = Array.isArray(obj) ? [] : {};
|
|
56
100
|
for (const [key, value] of Object.entries(obj)) {
|
|
57
101
|
if (this.isObject(value)) {
|
|
58
102
|
if (value instanceof serialize_1.LocaleString) {
|
|
59
|
-
|
|
103
|
+
result[key] = this.transformLocaleString(value, lang);
|
|
60
104
|
}
|
|
61
105
|
else if (value instanceof serialize_1.LocaleObject) {
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
delete obj[key];
|
|
106
|
+
const transformed = this.transformLocaleObject(value, lang, depth);
|
|
107
|
+
if (transformed !== undefined) {
|
|
108
|
+
result[key] = transformed;
|
|
68
109
|
}
|
|
69
110
|
}
|
|
111
|
+
else if (Array.isArray(value)) {
|
|
112
|
+
result[key] = value.map((item) => {
|
|
113
|
+
if (this.isObject(item)) {
|
|
114
|
+
return this.transformObject(item, lang, depth + 1);
|
|
115
|
+
}
|
|
116
|
+
return item;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
70
119
|
else {
|
|
71
|
-
|
|
120
|
+
result[key] = this.transformObject(value, lang, depth + 1);
|
|
72
121
|
}
|
|
73
122
|
}
|
|
74
|
-
else if (Array.isArray(
|
|
75
|
-
|
|
123
|
+
else if (Array.isArray(value)) {
|
|
124
|
+
result[key] = value.map((item) => {
|
|
125
|
+
if (this.isObject(item)) {
|
|
126
|
+
return this.transformObject(item, lang, depth + 1);
|
|
127
|
+
}
|
|
128
|
+
return item;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
result[key] = value;
|
|
76
133
|
}
|
|
77
134
|
}
|
|
78
|
-
return
|
|
135
|
+
return result;
|
|
79
136
|
}
|
|
80
137
|
transformLocaleString(obj, lang) {
|
|
81
138
|
if (!obj)
|
|
@@ -86,18 +143,18 @@ let SerializableInterceptor = class SerializableInterceptor extends common_1.Cla
|
|
|
86
143
|
return obj[this.fallbackLanguage];
|
|
87
144
|
return "";
|
|
88
145
|
}
|
|
89
|
-
transformLocaleObject(obj, lang) {
|
|
146
|
+
transformLocaleObject(obj, lang, depth = 0) {
|
|
90
147
|
if (!obj)
|
|
91
148
|
return '';
|
|
92
149
|
let value = obj[lang];
|
|
93
150
|
if (!value) {
|
|
94
151
|
value = obj[this.fallbackLanguage];
|
|
95
152
|
}
|
|
96
|
-
return value ? this.transformObject(value, lang) : undefined;
|
|
153
|
+
return value ? this.transformObject(value, lang, depth + 1) : undefined;
|
|
97
154
|
}
|
|
98
155
|
};
|
|
99
156
|
exports.SerializableInterceptor = SerializableInterceptor;
|
|
100
|
-
exports.SerializableInterceptor = SerializableInterceptor = __decorate([
|
|
157
|
+
exports.SerializableInterceptor = SerializableInterceptor = SerializableInterceptor_1 = __decorate([
|
|
101
158
|
(0, common_1.Injectable)(),
|
|
102
159
|
__param(0, (0, common_1.Inject)(constant_1.REFLECTOR)),
|
|
103
160
|
__param(1, (0, common_1.Optional)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializable.interceptor.js","sourceRoot":"","sources":["../../lib/interceptor/serializable.interceptor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serializable.interceptor.js","sourceRoot":"","sources":["../../lib/interceptor/serializable.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwM;AACxM,yDAA8E;AAC9E,+BAAuC;AACvC,4CAAwE;AACxE,0CAAwC;AAExC,MAAM,SAAS,GAAG,GAAG,CAAC;AAQf,IAAM,uBAAuB,+BAA7B,MAAM,uBAAwB,SAAQ,mCAA0B;IAIrE,YACqB,SAAiC,EAEpD,iBAAuE,EAAE;QAEzE,KAAK,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAJK,cAAS,GAAT,SAAS,CAAK;QAEjC,mBAAc,GAAd,cAAc,CAAwC;QAN1D,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;QAC3D,qBAAgB,GAAG,OAAO,CAAC;QA6KnC,aAAQ,GAAG,CAAC,EAAO,EAAgB,EAAE,CACnC,CAA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AAC;QAEpB,IAAI,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;QAEhC,IAAI,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAElE,OAAO,EAAE,CAAC;IACZ,CAAC;IAMD,qBAAqB,CAAC,GAAiB,EAAE,IAAY,EAAE,KAAK,GAAG,CAAC;QAC9D,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,CAAC;QAEpB,IAAI,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QAEtB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,CAAC;CAUF,CAAA;AAvLY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,oBAAS,CAAC,CAAA;IACjB,WAAA,IAAA,iBAAQ,GAAE,CAAA;;GANF,uBAAuB,CAuLnC"}
|
package/dist/ip/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { getClientIp, mw, configureTrustProxy, isTrustProxyConfigured, getTrustProxySource, TrustProxyOptions } from './request-ip';
|
|
2
|
-
|
|
1
|
+
import { getClientIp, mw, configureTrustProxy, isTrustProxyConfigured, getTrustProxySource, type TrustProxyOptions } from './request-ip';
|
|
2
|
+
import { type TrustedProxyProvider, TRUSTED_PROXY_PRESETS, resolveProviderCidrs } from './trusted-proxy-presets';
|
|
3
|
+
export { getClientIp, mw as RequestIpMiddleware, configureTrustProxy, isTrustProxyConfigured, getTrustProxySource, type TrustProxyOptions, type TrustedProxyProvider, TRUSTED_PROXY_PRESETS, resolveProviderCidrs, };
|
package/dist/ip/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTrustProxySource = exports.isTrustProxyConfigured = exports.configureTrustProxy = exports.RequestIpMiddleware = exports.getClientIp = void 0;
|
|
3
|
+
exports.resolveProviderCidrs = exports.TRUSTED_PROXY_PRESETS = exports.getTrustProxySource = exports.isTrustProxyConfigured = exports.configureTrustProxy = exports.RequestIpMiddleware = exports.getClientIp = void 0;
|
|
4
4
|
const request_ip_1 = require("./request-ip");
|
|
5
5
|
Object.defineProperty(exports, "getClientIp", { enumerable: true, get: function () { return request_ip_1.getClientIp; } });
|
|
6
6
|
Object.defineProperty(exports, "RequestIpMiddleware", { enumerable: true, get: function () { return request_ip_1.mw; } });
|
|
7
7
|
Object.defineProperty(exports, "configureTrustProxy", { enumerable: true, get: function () { return request_ip_1.configureTrustProxy; } });
|
|
8
8
|
Object.defineProperty(exports, "isTrustProxyConfigured", { enumerable: true, get: function () { return request_ip_1.isTrustProxyConfigured; } });
|
|
9
9
|
Object.defineProperty(exports, "getTrustProxySource", { enumerable: true, get: function () { return request_ip_1.getTrustProxySource; } });
|
|
10
|
+
const trusted_proxy_presets_1 = require("./trusted-proxy-presets");
|
|
11
|
+
Object.defineProperty(exports, "TRUSTED_PROXY_PRESETS", { enumerable: true, get: function () { return trusted_proxy_presets_1.TRUSTED_PROXY_PRESETS; } });
|
|
12
|
+
Object.defineProperty(exports, "resolveProviderCidrs", { enumerable: true, get: function () { return trusted_proxy_presets_1.resolveProviderCidrs; } });
|
|
10
13
|
//# sourceMappingURL=index.js.map
|
package/dist/ip/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/ip/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/ip/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyI;AAIvI,4FAJO,wBAAW,OAIP;AACL,oGALc,eAAE,OAKG;AACzB,oGANwB,gCAAmB,OAMxB;AACnB,uGAP6C,mCAAsB,OAO7C;AACtB,oGARqE,gCAAmB,OAQrE;AAPrB,mEAAiH;AAU/G,sGAVkC,6CAAqB,OAUlC;AACrB,qGAXyD,4CAAoB,OAWzD"}
|
package/dist/ip/request-ip.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { type TrustedProxyProvider } from './trusted-proxy-presets';
|
|
1
2
|
export interface TrustProxyOptions {
|
|
2
3
|
enabled?: boolean;
|
|
3
4
|
trustedProxies?: string[];
|
|
5
|
+
providers?: TrustedProxyProvider | TrustedProxyProvider[];
|
|
4
6
|
}
|
|
5
7
|
export declare function configureTrustProxy(options: TrustProxyOptions, source?: string): void;
|
|
6
8
|
export declare function isTrustProxyConfigured(): boolean;
|
|
7
9
|
export declare function getTrustProxySource(): string | null;
|
|
8
|
-
declare function getClientIpFromXForwardedFor(value: string): string | null;
|
|
9
|
-
declare function getClientIpByHeader(req: any, header: string): string | undefined | null;
|
|
10
|
+
declare function getClientIpFromXForwardedFor(value: string, trustedProxies?: string[]): string | null;
|
|
11
|
+
declare function getClientIpByHeader(req: any, header: string, trustedProxies?: string[]): string | undefined | null;
|
|
10
12
|
declare function getClientIp(req: any): string;
|
|
11
13
|
declare function mw(options?: {
|
|
12
14
|
attributeName?: string;
|