@nathapp/nestjs-common 1.0.1-rc.9 → 1.0.1

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 (158) hide show
  1. package/README.md +12 -16
  2. package/dist/config/index.d.ts +4 -1
  3. package/dist/config/index.js +7 -1
  4. package/dist/config/index.js.map +1 -0
  5. package/dist/config/server-security.config.d.ts +19 -0
  6. package/dist/config/server-security.config.js +65 -0
  7. package/dist/config/server-security.config.js.map +1 -0
  8. package/dist/config/utils/joi-util.js +1 -0
  9. package/dist/config/utils/joi-util.js.map +1 -0
  10. package/dist/config/utils/validate-util.d.ts +1 -0
  11. package/dist/config/utils/validate-util.js +3 -2
  12. package/dist/config/utils/validate-util.js.map +1 -0
  13. package/dist/constant/common-constant.d.ts +1 -0
  14. package/dist/constant/common-constant.js +5 -0
  15. package/dist/constant/common-constant.js.map +1 -0
  16. package/dist/constant/index.d.ts +2 -0
  17. package/dist/constant/index.js +6 -0
  18. package/dist/constant/index.js.map +1 -0
  19. package/dist/decorator/client-info.decorator.d.ts +10 -1
  20. package/dist/decorator/client-info.decorator.js +7 -6
  21. package/dist/decorator/client-info.decorator.js.map +1 -0
  22. package/dist/decorator/index.d.ts +2 -2
  23. package/dist/decorator/index.js +3 -2
  24. package/dist/decorator/index.js.map +1 -0
  25. package/dist/decorator/real-ip.decorator.js +3 -2
  26. package/dist/decorator/real-ip.decorator.js.map +1 -0
  27. package/dist/exception/app-exception-code.enum.d.ts +3 -1
  28. package/dist/exception/app-exception-code.enum.js +5 -2
  29. package/dist/exception/app-exception-code.enum.js.map +1 -0
  30. package/dist/exception/app-exception.filter.js +3 -2
  31. package/dist/exception/app-exception.filter.js.map +1 -0
  32. package/dist/exception/app.exception.js +1 -0
  33. package/dist/exception/app.exception.js.map +1 -0
  34. package/dist/exception/default-i18n-validation-exception.filter.d.ts +11 -0
  35. package/dist/exception/default-i18n-validation-exception.filter.js +43 -0
  36. package/dist/exception/default-i18n-validation-exception.filter.js.map +1 -0
  37. package/dist/exception/global-exception.filter.d.ts +12 -0
  38. package/dist/exception/global-exception.filter.js +49 -5
  39. package/dist/exception/global-exception.filter.js.map +1 -0
  40. package/dist/exception/i18n-validation-exception.filter.d.ts +13 -0
  41. package/dist/exception/i18n-validation-exception.filter.js +88 -0
  42. package/dist/exception/i18n-validation-exception.filter.js.map +1 -0
  43. package/dist/exception/index.d.ts +4 -1
  44. package/dist/exception/index.js +9 -1
  45. package/dist/exception/index.js.map +1 -0
  46. package/dist/exception/micro-service.exception.d.ts +6 -0
  47. package/dist/exception/micro-service.exception.js +16 -0
  48. package/dist/exception/micro-service.exception.js.map +1 -0
  49. package/dist/exception/user-not-found.exception.js +1 -0
  50. package/dist/exception/user-not-found.exception.js.map +1 -0
  51. package/dist/http/index.d.ts +3 -0
  52. package/dist/http/index.js +3 -0
  53. package/dist/http/index.js.map +1 -0
  54. package/dist/http/request.d.ts +3 -0
  55. package/dist/http/request.js +3 -0
  56. package/dist/http/request.js.map +1 -0
  57. package/dist/http/response.d.ts +3 -0
  58. package/dist/http/response.js +3 -0
  59. package/dist/http/response.js.map +1 -0
  60. package/dist/i18n/i18n-core.module.js +4 -2
  61. package/dist/i18n/i18n-core.module.js.map +1 -0
  62. package/dist/i18n/i18n.constants.js +1 -0
  63. package/dist/i18n/i18n.constants.js.map +1 -0
  64. package/dist/i18n/index.js +1 -0
  65. package/dist/i18n/index.js.map +1 -0
  66. package/dist/index.d.ts +10 -2
  67. package/dist/index.js +11 -2
  68. package/dist/index.js.map +1 -0
  69. package/dist/interceptor/index.d.ts +2 -0
  70. package/dist/interceptor/index.js +6 -0
  71. package/dist/interceptor/index.js.map +1 -0
  72. package/dist/interceptor/serializable.interceptor.d.ts +19 -0
  73. package/dist/interceptor/serializable.interceptor.js +106 -0
  74. package/dist/interceptor/serializable.interceptor.js.map +1 -0
  75. package/dist/ip/index.d.ts +2 -0
  76. package/dist/ip/index.js +7 -0
  77. package/dist/ip/index.js.map +1 -0
  78. package/dist/ip/is.d.ts +17 -0
  79. package/dist/ip/is.js +37 -0
  80. package/dist/ip/is.js.map +1 -0
  81. package/dist/ip/request-ip.d.ts +8 -0
  82. package/dist/ip/request-ip.js +180 -0
  83. package/dist/ip/request-ip.js.map +1 -0
  84. package/dist/logging/empty-logger.d.ts +8 -0
  85. package/dist/logging/empty-logger.js +12 -0
  86. package/dist/logging/empty-logger.js.map +1 -0
  87. package/dist/logging/index.d.ts +3 -0
  88. package/dist/logging/index.js +8 -0
  89. package/dist/logging/index.js.map +1 -0
  90. package/dist/logging/logger-utils.d.ts +2 -0
  91. package/dist/logging/logger-utils.js +11 -0
  92. package/dist/logging/logger-utils.js.map +1 -0
  93. package/dist/middleware/index.d.ts +4 -1
  94. package/dist/middleware/index.js +12 -1
  95. package/dist/middleware/index.js.map +1 -0
  96. package/dist/middleware/json-body.middleware.js +3 -2
  97. package/dist/middleware/json-body.middleware.js.map +1 -0
  98. package/dist/middleware/log.provider.d.ts +34 -0
  99. package/dist/middleware/log.provider.js +143 -0
  100. package/dist/middleware/log.provider.js.map +1 -0
  101. package/dist/middleware/logger-option.factory.d.ts +15 -0
  102. package/dist/middleware/logger-option.factory.js +63 -0
  103. package/dist/middleware/logger-option.factory.js.map +1 -0
  104. package/dist/middleware/logger.middleware.d.ts +8 -0
  105. package/dist/middleware/logger.middleware.js +92 -0
  106. package/dist/middleware/logger.middleware.js.map +1 -0
  107. package/dist/middleware/raw-body.middleware.js +3 -2
  108. package/dist/middleware/raw-body.middleware.js.map +1 -0
  109. package/dist/module/configurable-module-cls.interface.d.ts +5 -0
  110. package/dist/module/configurable-module-cls.interface.js +3 -0
  111. package/dist/module/configurable-module-cls.interface.js.map +1 -0
  112. package/dist/module/configurable-module-host.interface.d.ts +5 -0
  113. package/dist/module/configurable-module-host.interface.js +3 -0
  114. package/dist/module/configurable-module-host.interface.js.map +1 -0
  115. package/dist/module/configurable-module.builder.d.ts +26 -0
  116. package/dist/module/configurable-module.builder.js +191 -0
  117. package/dist/module/configurable-module.builder.js.map +1 -0
  118. package/dist/module/index.d.ts +5 -0
  119. package/dist/module/index.js +10 -0
  120. package/dist/module/index.js.map +1 -0
  121. package/dist/module/module.interface.d.ts +8 -0
  122. package/dist/module/module.interface.js +8 -0
  123. package/dist/module/module.interface.js.map +1 -0
  124. package/dist/serialize/index.d.ts +4 -2
  125. package/dist/serialize/index.js +21 -3
  126. package/dist/serialize/index.js.map +1 -0
  127. package/dist/serialize/json-response.d.ts +1 -1
  128. package/dist/serialize/json-response.js +2 -1
  129. package/dist/serialize/json-response.js.map +1 -0
  130. package/dist/serialize/localize.string.d.ts +6 -0
  131. package/dist/serialize/localize.string.js +35 -1
  132. package/dist/serialize/localize.string.js.map +1 -0
  133. package/dist/serialize/serializable.d.ts +2 -0
  134. package/dist/serialize/serializable.js +7 -0
  135. package/dist/serialize/serializable.js.map +1 -0
  136. package/dist/utils/index.d.ts +2 -0
  137. package/dist/utils/index.js +7 -0
  138. package/dist/utils/index.js.map +1 -0
  139. package/dist/utils/package-utils.d.ts +2 -0
  140. package/dist/utils/package-utils.js +18 -0
  141. package/dist/utils/package-utils.js.map +1 -0
  142. package/dist/validation/i18n-validation.constraint.d.ts +9 -0
  143. package/dist/validation/i18n-validation.constraint.js +13 -0
  144. package/dist/validation/i18n-validation.constraint.js.map +1 -0
  145. package/dist/validation/index.d.ts +3 -0
  146. package/dist/validation/index.js +20 -0
  147. package/dist/validation/index.js.map +1 -0
  148. package/dist/validation/match.constraint.d.ts +8 -0
  149. package/dist/validation/match.constraint.js +39 -0
  150. package/dist/validation/match.constraint.js.map +1 -0
  151. package/dist/validation/validation.d.ts +28 -0
  152. package/dist/validation/validation.js +77 -0
  153. package/dist/validation/validation.js.map +1 -0
  154. package/index.d.ts +1 -1
  155. package/index.js +16 -5
  156. package/package.json +28 -23
  157. package/.eslintrc.js +0 -24
  158. package/lib/config/README.md +0 -7
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseI18nValidatorConstraint = void 0;
4
+ class BaseI18nValidatorConstraint {
5
+ constructor(i18nService) {
6
+ this.i18nService = i18nService;
7
+ }
8
+ translate(key, args, prefix = 'exception') {
9
+ return this.i18nService.t(`${prefix}.${key}`, args);
10
+ }
11
+ }
12
+ exports.BaseI18nValidatorConstraint = BaseI18nValidatorConstraint;
13
+ //# sourceMappingURL=i18n-validation.constraint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n-validation.constraint.js","sourceRoot":"","sources":["../../lib/validation/i18n-validation.constraint.ts"],"names":[],"mappings":";;;AAMA,MAAsB,2BAA2B;IAG/C,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAMzD,SAAS,CAAC,GAAW,EAAE,IAAU,EAAE,MAAM,GAAG,WAAW;QACrD,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACF;AAZD,kEAYC"}
@@ -0,0 +1,3 @@
1
+ export * from './match.constraint';
2
+ export * from './i18n-validation.constraint';
3
+ export * from './validation';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./match.constraint"), exports);
18
+ __exportStar(require("./i18n-validation.constraint"), exports);
19
+ __exportStar(require("./validation"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/validation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,+DAA6C;AAC7C,+CAA6B"}
@@ -0,0 +1,8 @@
1
+ import { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
2
+ import { I18nValidationOptions } from './validation';
3
+ export declare const MatchWithI18n: <T>(property: keyof T, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => (object: any, propertyName: string) => void;
4
+ export declare const Match: <T>(property: keyof T, options?: ValidationOptions) => (object: any, propertyName: string) => void;
5
+ export declare class MatchConstraint implements ValidatorConstraintInterface {
6
+ validate(value: any, args?: ValidationArguments): boolean;
7
+ defaultMessage(args?: ValidationArguments): string;
8
+ }
@@ -0,0 +1,39 @@
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.MatchConstraint = exports.Match = exports.MatchWithI18n = void 0;
10
+ const class_validator_1 = require("class-validator");
11
+ const validation_1 = require("./validation");
12
+ const MatchWithI18n = (property, validationOptions, args, key = 'match', prefix = 'validation') => {
13
+ return (0, exports.Match)(property, (0, validation_1.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
14
+ };
15
+ exports.MatchWithI18n = MatchWithI18n;
16
+ const Match = (property, options) => (object, propertyName) => (0, class_validator_1.registerDecorator)({
17
+ target: object.constructor,
18
+ propertyName,
19
+ options,
20
+ constraints: [property],
21
+ validator: MatchConstraint,
22
+ });
23
+ exports.Match = Match;
24
+ let MatchConstraint = class MatchConstraint {
25
+ validate(value, args) {
26
+ const [propertyNameToCompare] = (args === null || args === void 0 ? void 0 : args.constraints) || [];
27
+ const propertyValue = (args === null || args === void 0 ? void 0 : args.object)[propertyNameToCompare];
28
+ return (0, class_validator_1.equals)(value, propertyValue);
29
+ }
30
+ defaultMessage(args) {
31
+ const [propertyNameToCompare] = (args === null || args === void 0 ? void 0 : args.constraints) || [];
32
+ return `${args === null || args === void 0 ? void 0 : args.property} does not match with ${propertyNameToCompare}`;
33
+ }
34
+ };
35
+ exports.MatchConstraint = MatchConstraint;
36
+ exports.MatchConstraint = MatchConstraint = __decorate([
37
+ (0, class_validator_1.ValidatorConstraint)({ name: 'Match' })
38
+ ], MatchConstraint);
39
+ //# sourceMappingURL=match.constraint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.constraint.js","sourceRoot":"","sources":["../../lib/validation/match.constraint.ts"],"names":[],"mappings":";;;;;;;;;AACA,qDAOyB;AACzB,6CAAmF;AAE5E,MAAM,aAAa,GAAG,CAAI,QAAiB,EAAE,iBAAyC,EAC3F,IAAU,EACV,GAAG,GAAG,OAAO,EACb,MAAM,GAAG,YAAY,EAAG,EAAE;IAE1B,OAAO,IAAA,aAAK,EAAC,QAAQ,EAAE,IAAA,yCAA4B,EAAC,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC7F,CAAC,CAAA;AANY,QAAA,aAAa,iBAMzB;AAEM,MAAM,KAAK,GAChB,CAAI,QAAiB,EAAE,OAA2B,EAAE,EAAE,CACpD,CAAC,MAAW,EAAE,YAAoB,EAAE,EAAE,CACpC,IAAA,mCAAiB,EAAC;IAChB,MAAM,EAAE,MAAM,CAAC,WAAW;IAC1B,YAAY;IACZ,OAAO;IACP,WAAW,EAAE,CAAC,QAAQ,CAAC;IACvB,SAAS,EAAE,eAAe;CAC3B,CAAC,CAAC;AATI,QAAA,KAAK,SAST;AAGF,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,QAAQ,CAAC,KAAU,EAAE,IAA0B;QAC7C,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,KAAI,EAAE,CAAC;QACxD,MAAM,aAAa,GAAG,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAc,CAAA,CAAC,qBAAqB,CAAC,CAAC;QACnE,OAAO,IAAA,wBAAM,EAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACtC,CAAC;IAED,cAAc,CAAC,IAA0B;QACvC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,KAAI,EAAE,CAAC;QAExD,OAAO,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,wBAAwB,qBAAqB,EAAE,CAAC;IAC1E,CAAC;CACF,CAAA;AAZY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,qCAAmB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;GAC1B,eAAe,CAY3B"}
@@ -0,0 +1,28 @@
1
+ import { IsStrongPasswordOptions, ValidationOptions } from 'class-validator';
2
+ import { IsEmailOptions, IsFQDNOptions } from 'validator';
3
+ export type I18nValidationOptions = Omit<ValidationOptions, 'message'>;
4
+ export declare const resolveI18nValidationOptions: (options: I18nValidationOptions, key: string, prefix: string, args?: any) => {
5
+ each?: boolean;
6
+ groups?: string[];
7
+ always?: boolean;
8
+ context?: any;
9
+ message: (a: import("class-validator").ValidationArguments) => string;
10
+ };
11
+ export declare const resolveI18nValidationMessage: (key: string, prefix: string, args?: any) => (a: import("class-validator").ValidationArguments) => string;
12
+ export declare const IsNotEmptyWithI18n: (validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
13
+ export declare const IsStringWithI18n: (validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
14
+ export declare const IsBooleanWithI18n: (validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
15
+ export declare const IsEmailWithI18n: (options?: IsEmailOptions, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
16
+ export declare const MinWithI18n: (minValue: number, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
17
+ export declare const MaxWithI18n: (maxValue: number, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
18
+ export declare const LengthWithI18n: (minValue: number, maxValue?: number, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
19
+ export declare const MinLengthWithI18n: (minLength: number, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
20
+ export declare const MaxLengthWithI18n: (maxLength: number, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
21
+ export declare const IsIntWithI18n: (validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
22
+ export declare const ContainsWithI18n: (seed: string, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
23
+ export declare const IsFQDNWithI18n: (options?: IsFQDNOptions, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
24
+ export declare const IsDateWithI18n: (validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
25
+ export declare const IsNotEmptyObjectWithI18n: (options?: {
26
+ nullable?: boolean;
27
+ }, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
28
+ export declare const IsStrongPasswordWithI18n: (options?: IsStrongPasswordOptions, validationOptions?: I18nValidationOptions, args?: any, key?: string, prefix?: string) => PropertyDecorator;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsStrongPasswordWithI18n = exports.IsNotEmptyObjectWithI18n = exports.IsDateWithI18n = exports.IsFQDNWithI18n = exports.ContainsWithI18n = exports.IsIntWithI18n = exports.MaxLengthWithI18n = exports.MinLengthWithI18n = exports.LengthWithI18n = exports.MaxWithI18n = exports.MinWithI18n = exports.IsEmailWithI18n = exports.IsBooleanWithI18n = exports.IsStringWithI18n = exports.IsNotEmptyWithI18n = exports.resolveI18nValidationMessage = exports.resolveI18nValidationOptions = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ const nestjs_i18n_1 = require("nestjs-i18n");
6
+ const resolveI18nValidationOptions = (options, key, prefix, args) => {
7
+ return {
8
+ message: (0, exports.resolveI18nValidationMessage)(key, prefix, args),
9
+ ...options,
10
+ };
11
+ };
12
+ exports.resolveI18nValidationOptions = resolveI18nValidationOptions;
13
+ const resolveI18nValidationMessage = (key, prefix, args) => {
14
+ return (0, nestjs_i18n_1.i18nValidationMessage)(`${prefix}.${key}`, args);
15
+ };
16
+ exports.resolveI18nValidationMessage = resolveI18nValidationMessage;
17
+ const IsNotEmptyWithI18n = (validationOptions, args, key = 'isNotEmpty', prefix = 'validation') => {
18
+ return (0, class_validator_1.IsNotEmpty)((0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
19
+ };
20
+ exports.IsNotEmptyWithI18n = IsNotEmptyWithI18n;
21
+ const IsStringWithI18n = (validationOptions, args, key = 'isString', prefix = 'validation') => {
22
+ return (0, class_validator_1.IsString)((0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
23
+ };
24
+ exports.IsStringWithI18n = IsStringWithI18n;
25
+ const IsBooleanWithI18n = (validationOptions, args, key = 'isBoolean', prefix = 'validation') => {
26
+ return (0, class_validator_1.IsBoolean)((0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
27
+ };
28
+ exports.IsBooleanWithI18n = IsBooleanWithI18n;
29
+ const IsEmailWithI18n = (options, validationOptions, args, key = 'isEmail', prefix = 'validation') => {
30
+ return (0, class_validator_1.IsEmail)(options, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
31
+ };
32
+ exports.IsEmailWithI18n = IsEmailWithI18n;
33
+ const MinWithI18n = (minValue, validationOptions, args, key = 'min', prefix = 'validation') => {
34
+ return (0, class_validator_1.Min)(minValue, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
35
+ };
36
+ exports.MinWithI18n = MinWithI18n;
37
+ const MaxWithI18n = (maxValue, validationOptions, args, key = 'max', prefix = 'validation') => {
38
+ return (0, class_validator_1.Max)(maxValue, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
39
+ };
40
+ exports.MaxWithI18n = MaxWithI18n;
41
+ const LengthWithI18n = (minValue, maxValue, validationOptions, args, key = 'length', prefix = 'validation') => {
42
+ return (0, class_validator_1.Length)(minValue, maxValue, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
43
+ };
44
+ exports.LengthWithI18n = LengthWithI18n;
45
+ const MinLengthWithI18n = (minLength, validationOptions, args, key = 'minLength', prefix = 'validation') => {
46
+ return (0, class_validator_1.MinLength)(minLength, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
47
+ };
48
+ exports.MinLengthWithI18n = MinLengthWithI18n;
49
+ const MaxLengthWithI18n = (maxLength, validationOptions, args, key = 'maxLength', prefix = 'validation') => {
50
+ return (0, class_validator_1.MaxLength)(maxLength, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
51
+ };
52
+ exports.MaxLengthWithI18n = MaxLengthWithI18n;
53
+ const IsIntWithI18n = (validationOptions, args, key = 'isInt', prefix = 'validation') => {
54
+ return (0, class_validator_1.IsInt)((0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
55
+ };
56
+ exports.IsIntWithI18n = IsIntWithI18n;
57
+ const ContainsWithI18n = (seed, validationOptions, args, key = 'contains', prefix = 'validation') => {
58
+ return (0, class_validator_1.Contains)(seed, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
59
+ };
60
+ exports.ContainsWithI18n = ContainsWithI18n;
61
+ const IsFQDNWithI18n = (options, validationOptions, args, key = 'isFQDN', prefix = 'validation') => {
62
+ return (0, class_validator_1.IsFQDN)(options, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
63
+ };
64
+ exports.IsFQDNWithI18n = IsFQDNWithI18n;
65
+ const IsDateWithI18n = (validationOptions, args, key = 'IsDate', prefix = 'validation') => {
66
+ return (0, class_validator_1.IsDate)((0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
67
+ };
68
+ exports.IsDateWithI18n = IsDateWithI18n;
69
+ const IsNotEmptyObjectWithI18n = (options, validationOptions, args, key = 'isNotEmptyObject', prefix = 'validation') => {
70
+ return (0, class_validator_1.IsNotEmptyObject)(options, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
71
+ };
72
+ exports.IsNotEmptyObjectWithI18n = IsNotEmptyObjectWithI18n;
73
+ const IsStrongPasswordWithI18n = (options, validationOptions, args, key = 'isStrongPassword', prefix = 'validation') => {
74
+ return (0, class_validator_1.IsStrongPassword)(options, (0, exports.resolveI18nValidationOptions)(validationOptions, key, prefix, args));
75
+ };
76
+ exports.IsStrongPasswordWithI18n = IsStrongPasswordWithI18n;
77
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../lib/validation/validation.ts"],"names":[],"mappings":";;;AAAA,qDAAoO;AACpO,6CAAoD;AAM7C,MAAM,4BAA4B,GAAG,CAAC,OAA8B,EAAE,GAAW,EAAE,MAAc,EAAE,IAAU,EAAE,EAAE;IACtH,OAAO;QACL,OAAO,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AO,EAAE,IAAA,oCAA4B,EAAC,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC7F,CAAC,CAAA;AAFY,QAAA,cAAc,kBAE1B;AAEM,MAAM,cAAc,GAAG,CAAC,iBAAyC,EAAE,IAAU,EAAE,GAAG,GAAG,QAAQ,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE;IAC7H,OAAO,IAAA,wBAAM,EAAC,IAAA,oCAA4B,EAAC,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AACpF,CAAC,CAAA;AAFY,QAAA,cAAc,kBAE1B;AAEM,MAAM,wBAAwB,GAAG,CAAC,OAExC,EAAE,iBAAyC,EAAE,IAAU,EAAE,GAAG,GAAG,kBAAkB,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE;IAC3G,OAAO,IAAA,kCAAgB,EAAC,OAAO,EAAE,IAAA,oCAA4B,EAAC,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AACvG,CAAC,CAAA;AAJY,QAAA,wBAAwB,4BAIpC;AAEM,MAAM,wBAAwB,GAAG,CAAC,OAAiC,EAAE,iBAAyC,EAAE,IAAU,EAAE,GAAG,GAAG,kBAAkB,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE;IACpL,OAAO,IAAA,kCAAgB,EAAC,OAAO,EAAE,IAAA,oCAA4B,EAAC,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AACvG,CAAC,CAAA;AAFY,QAAA,wBAAwB,4BAEpC"}
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./dist";
1
+ export * from './dist';
package/index.js CHANGED
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
5
- exports.__esModule = true;
6
- __export(require("./dist"));
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./dist"), exports);
package/package.json CHANGED
@@ -1,29 +1,32 @@
1
1
  {
2
2
  "name": "@nathapp/nestjs-common",
3
- "version": "1.0.1-rc.9",
3
+ "version": "1.0.1",
4
4
  "description": "NestJs Common Library",
5
5
  "scripts": {
6
+ "clean": "rimraf dist/ .turbo/",
6
7
  "build": "rimraf dist && tsc -p tsconfig.json",
7
8
  "precommit": "lint-staged",
8
- "test": "jest",
9
- "test:watch": "jest --watch",
10
- "test:cov": "jest --coverage",
11
- "test:e2e": "jest --config ./test/jest-e2e.json",
9
+ "test": "jest --config ./test/jest-test.json",
10
+ "test:cov": "jest --config ./test/jest-test.json --coverage",
11
+ "test:watch": "jest --config ./test/jest-test.json --watch",
12
12
  "lint": "eslint -c .eslintrc.js"
13
13
  },
14
+ "exports": {
15
+ ".": "./dist/index.js"
16
+ },
14
17
  "author": "",
15
18
  "license": "ISC",
19
+ "engines": {
20
+ "node": ">=16"
21
+ },
16
22
  "devDependencies": {
17
- "@nestjs/platform-express": "^9.0.0",
18
- "@nestjs/platform-fastify": "^9.0.0",
19
- "@types/node": "^17.0.22",
20
- "@typescript-eslint/eslint-plugin": "^4",
21
- "@typescript-eslint/parser": "^4",
22
- "eslint": "*",
23
- "eslint-config-prettier": "^6",
24
- "eslint-plugin-prettier": "^3",
25
- "prettier": "^2",
26
- "typescript": "^4"
23
+ "@nathapp/eslint-config": "1.0.1",
24
+ "@nathapp/typescript-config": "1.0.1",
25
+ "@nestjs/throttler": "^5.0.1",
26
+ "@types/body-parser": "^1.19.2",
27
+ "@types/express": "^4.17.17",
28
+ "eslint": "^8.57.0",
29
+ "typescript": "^5"
27
30
  },
28
31
  "types": "./index.d.ts",
29
32
  "main": "index.js",
@@ -31,17 +34,19 @@
31
34
  "lib": "lib"
32
35
  },
33
36
  "dependencies": {
34
- "@nathapp/common": "^0.1.10",
37
+ "@nathapp/common": "^0.1.14",
38
+ "body-parser": "^1.20.2",
35
39
  "joi": "^17.6.0",
36
- "nestjs-i18n": "^10.0.0",
37
- "request-ip": "^3.2.0"
40
+ "nestjs-i18n": "^10.4.5"
38
41
  },
39
42
  "peerDependencies": {
40
- "@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0",
41
- "@nestjs/config": "^1.0.0 || ^2.0.0 || ^3.0.0",
42
- "@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0",
43
+ "@nestjs/throttler": "^5.0.0",
43
44
  "class-transformer": "*",
44
- "class-validator": "*",
45
- "rxjs": "*"
45
+ "class-validator": "*"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "@nestjs/throttler": {
49
+ "optional": true
50
+ }
46
51
  }
47
52
  }
package/.eslintrc.js DELETED
@@ -1,24 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- project: 'tsconfig.json',
5
- sourceType: 'module',
6
- },
7
- plugins: ['@typescript-eslint/eslint-plugin'],
8
- extends: [
9
- 'plugin:@typescript-eslint/recommended',
10
- 'plugin:prettier/recommended',
11
- ],
12
- root: true,
13
- env: {
14
- node: true,
15
- jest: true,
16
- },
17
- ignorePatterns: ['.eslintrc.js'],
18
- rules: {
19
- '@typescript-eslint/interface-name-prefix': 'off',
20
- '@typescript-eslint/explicit-function-return-type': 'off',
21
- '@typescript-eslint/explicit-module-boundary-types': 'off',
22
- '@typescript-eslint/no-explicit-any': 'off',
23
- },
24
- };
@@ -1,7 +0,0 @@
1
- ## Using Joi Utils and Validate Utils to validate config
2
-
3
- 1. create an config interface
4
-
5
- 2. create a validation class to schema validation
6
-
7
- https://dev.to/rrgt19/ways-to-validate-environment-configuration-in-a-forfeature-config-in-nestjs-2ehp