@mondart/nestjs-common-module 1.0.3
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/.eslintrc.js +25 -0
- package/.github/workflows/npm-publish.yml +34 -0
- package/.prettierrc +4 -0
- package/common/caching/caching.module.ts +28 -0
- package/common/caching/caching.service.ts +34 -0
- package/common/caching/index.ts +2 -0
- package/common/constants/index.ts +1 -0
- package/common/constants/validation-constraints.const.ts +14 -0
- package/common/controllers/core-crud.controller.ts +106 -0
- package/common/controllers/index.ts +1 -0
- package/common/decorators/entity-order.decorator.ts +19 -0
- package/common/decorators/index.ts +2 -0
- package/common/decorators/swagger-api-response.decorator.ts +30 -0
- package/common/decorators/validations/default/array-max-size.decorator.ts +9 -0
- package/common/decorators/validations/default/array-min-size.decorator.ts +9 -0
- package/common/decorators/validations/default/array-not-empty.decorator.ts +7 -0
- package/common/decorators/validations/default/index.ts +20 -0
- package/common/decorators/validations/default/is-array.decorator.ts +7 -0
- package/common/decorators/validations/default/is-boolean.decorator.ts +10 -0
- package/common/decorators/validations/default/is-date.decorator.ts +10 -0
- package/common/decorators/validations/default/is-enum.decorator.ts +9 -0
- package/common/decorators/validations/default/is-int.decorator.ts +10 -0
- package/common/decorators/validations/default/is-not-empty-object.decorator.ts +15 -0
- package/common/decorators/validations/default/is-not-empty.decorator.ts +7 -0
- package/common/decorators/validations/default/is-number-string.decorator.ts +12 -0
- package/common/decorators/validations/default/is-object.decorator.ts +7 -0
- package/common/decorators/validations/default/is-positive.decorator.ts +10 -0
- package/common/decorators/validations/default/is-string.decorator.ts +8 -0
- package/common/decorators/validations/default/is-uuid.decorator.ts +7 -0
- package/common/decorators/validations/default/matches.decorator.ts +13 -0
- package/common/decorators/validations/default/max-length.decorator.ts +9 -0
- package/common/decorators/validations/default/max.decorator.ts +13 -0
- package/common/decorators/validations/default/min-length.decorator.ts +9 -0
- package/common/decorators/validations/default/min.decorator.ts +13 -0
- package/common/decorators/validations/index.ts +3 -0
- package/common/decorators/validations/is-id.decorator.ts +20 -0
- package/common/decorators/validations/is-not-empty-string.decorator.ts +14 -0
- package/common/dto/index.ts +2 -0
- package/common/dto/request/base-request.dto.ts +11 -0
- package/common/dto/request/event.dto.ts +25 -0
- package/common/dto/request/id.dto.ts +10 -0
- package/common/dto/request/ids.dto.ts +13 -0
- package/common/dto/request/index.ts +4 -0
- package/common/dto/response/base-response-with-action-dates.dto.ts +19 -0
- package/common/dto/response/base-response.dto.ts +10 -0
- package/common/dto/response/error-response.dto.ts +22 -0
- package/common/dto/response/index.ts +5 -0
- package/common/dto/response/kafka-success-response.dto.ts +56 -0
- package/common/dto/response/success-response.dto.ts +32 -0
- package/common/dto/response/validation.dto.ts +80 -0
- package/common/entities/action-dates.entity.ts +30 -0
- package/common/entities/base.entity.ts +7 -0
- package/common/entities/index.ts +2 -0
- package/common/entities/parent.entity.ts +35 -0
- package/common/enums/environments.enum.ts +6 -0
- package/common/enums/index.ts +2 -0
- package/common/enums/shared-messages.enum.ts +40 -0
- package/common/filters/http-exception.filter.ts +74 -0
- package/common/filters/index.ts +1 -0
- package/common/filters/rpc-exception.filter.ts +40 -0
- package/common/helper/get-env.helper.ts +3 -0
- package/common/helper/get-env.ts +3 -0
- package/common/helper/index.ts +2 -0
- package/common/helper/message-formatter.helper.ts +30 -0
- package/common/helper/multi-inheritance.helper.ts +12 -0
- package/common/helper/multi-inheritance.util.ts +12 -0
- package/common/index.ts +14 -0
- package/common/interface/core-crud-service.option.ts +8 -0
- package/common/interface/custom-validation-arguments.interface.ts +20 -0
- package/common/interface/index.ts +2 -0
- package/common/interface/kafka-success-response.interfase.ts +9 -0
- package/common/interface/pagination-query.ts +39 -0
- package/common/lib/index.ts +1 -0
- package/common/lib/kafka/constant/consumer.const.ts +13 -0
- package/common/lib/kafka/constant/kafka.const.ts +9 -0
- package/common/lib/kafka/index.ts +5 -0
- package/common/lib/kafka/kafka-admin.service.ts +51 -0
- package/common/lib/kafka/kafka-consumer.service.ts +59 -0
- package/common/lib/kafka/kafka-instance.const.ts +9 -0
- package/common/lib/kafka/kafka-logger.ts +25 -0
- package/common/lib/kafka/kafka-producer.service.ts +97 -0
- package/common/lib/kafka/kafka.interface.ts +22 -0
- package/common/lib/kafka/kafka.module.ts +80 -0
- package/common/lib/kafka/kafka.provider.ts +10 -0
- package/common/lib/kafka/kafka.service.ts +224 -0
- package/common/services/core-crud.service.ts +457 -0
- package/common/services/index.ts +1 -0
- package/common/strategy/index.ts +1 -0
- package/common/strategy/type-orm-naming.strategy.ts +17 -0
- package/common/validators/does-exist.validator.ts +42 -0
- package/common/validators/env.validator.ts +28 -0
- package/common/validators/index.ts +4 -0
- package/common/validators/is-unique.validator.ts +70 -0
- package/common/validators/validation-options.ts +38 -0
- package/dist/caching/caching.module.d.ts +2 -0
- package/dist/caching/caching.module.js +41 -0
- package/dist/caching/caching.module.js.map +1 -0
- package/dist/caching/caching.service.d.ts +9 -0
- package/dist/caching/caching.service.js +45 -0
- package/dist/caching/caching.service.js.map +1 -0
- package/dist/caching/index.d.ts +2 -0
- package/dist/caching/index.js +19 -0
- package/dist/caching/index.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +18 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/validation-constraints.const.d.ts +14 -0
- package/dist/constants/validation-constraints.const.js +19 -0
- package/dist/constants/validation-constraints.const.js.map +1 -0
- package/dist/controllers/core-crud.controller.d.ts +19 -0
- package/dist/controllers/core-crud.controller.js +72 -0
- package/dist/controllers/core-crud.controller.js.map +1 -0
- package/dist/controllers/index.d.ts +1 -0
- package/dist/controllers/index.js +18 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/decorators/entity-order.decorator.d.ts +2 -0
- package/dist/decorators/entity-order.decorator.js +18 -0
- package/dist/decorators/entity-order.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +19 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/swagger-api-response.decorator.d.ts +5 -0
- package/dist/decorators/swagger-api-response.decorator.js +25 -0
- package/dist/decorators/swagger-api-response.decorator.js.map +1 -0
- package/dist/decorators/validations/default/array-max-size.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/array-max-size.decorator.js +12 -0
- package/dist/decorators/validations/default/array-max-size.decorator.js.map +1 -0
- package/dist/decorators/validations/default/array-min-size.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/array-min-size.decorator.js +12 -0
- package/dist/decorators/validations/default/array-min-size.decorator.js.map +1 -0
- package/dist/decorators/validations/default/array-not-empty.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/array-not-empty.decorator.js +10 -0
- package/dist/decorators/validations/default/array-not-empty.decorator.js.map +1 -0
- package/dist/decorators/validations/default/index.d.ts +20 -0
- package/dist/decorators/validations/default/index.js +37 -0
- package/dist/decorators/validations/default/index.js.map +1 -0
- package/dist/decorators/validations/default/is-array.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/is-array.decorator.js +10 -0
- package/dist/decorators/validations/default/is-array.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-boolean.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-boolean.decorator.js +10 -0
- package/dist/decorators/validations/default/is-boolean.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-date.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-date.decorator.js +10 -0
- package/dist/decorators/validations/default/is-date.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-enum.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/is-enum.decorator.js +12 -0
- package/dist/decorators/validations/default/is-enum.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-int.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-int.decorator.js +10 -0
- package/dist/decorators/validations/default/is-int.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-not-empty-object.decorator.d.ts +5 -0
- package/dist/decorators/validations/default/is-not-empty-object.decorator.js +13 -0
- package/dist/decorators/validations/default/is-not-empty-object.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-not-empty.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/is-not-empty.decorator.js +10 -0
- package/dist/decorators/validations/default/is-not-empty.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-number-string.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-number-string.decorator.js +10 -0
- package/dist/decorators/validations/default/is-number-string.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-object.decorator.d.ts +2 -0
- package/dist/decorators/validations/default/is-object.decorator.js +10 -0
- package/dist/decorators/validations/default/is-object.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-positive.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-positive.decorator.js +10 -0
- package/dist/decorators/validations/default/is-positive.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-string.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-string.decorator.js +11 -0
- package/dist/decorators/validations/default/is-string.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-uuid.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-uuid.decorator.js +10 -0
- package/dist/decorators/validations/default/is-uuid.decorator.js.map +1 -0
- package/dist/decorators/validations/default/matches.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/matches.decorator.js +10 -0
- package/dist/decorators/validations/default/matches.decorator.js.map +1 -0
- package/dist/decorators/validations/default/max-length.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/max-length.decorator.js +12 -0
- package/dist/decorators/validations/default/max-length.decorator.js.map +1 -0
- package/dist/decorators/validations/default/max.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/max.decorator.js +10 -0
- package/dist/decorators/validations/default/max.decorator.js.map +1 -0
- package/dist/decorators/validations/default/min-length.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/min-length.decorator.js +12 -0
- package/dist/decorators/validations/default/min-length.decorator.js.map +1 -0
- package/dist/decorators/validations/default/min.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/min.decorator.js +10 -0
- package/dist/decorators/validations/default/min.decorator.js.map +1 -0
- package/dist/decorators/validations/index.d.ts +3 -0
- package/dist/decorators/validations/index.js +20 -0
- package/dist/decorators/validations/index.js.map +1 -0
- package/dist/decorators/validations/is-id.decorator.d.ts +4 -0
- package/dist/decorators/validations/is-id.decorator.js +21 -0
- package/dist/decorators/validations/is-id.decorator.js.map +1 -0
- package/dist/decorators/validations/is-not-empty-string.decorator.d.ts +4 -0
- package/dist/decorators/validations/is-not-empty-string.decorator.js +15 -0
- package/dist/decorators/validations/is-not-empty-string.decorator.js.map +1 -0
- package/dist/dto/index.d.ts +2 -0
- package/dist/dto/index.js +19 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/request/base-request.dto.d.ts +4 -0
- package/dist/dto/request/base-request.dto.js +24 -0
- package/dist/dto/request/base-request.dto.js.map +1 -0
- package/dist/dto/request/event.dto.d.ts +8 -0
- package/dist/dto/request/event.dto.js +45 -0
- package/dist/dto/request/event.dto.js.map +1 -0
- package/dist/dto/request/id.dto.d.ts +3 -0
- package/dist/dto/request/id.dto.js +25 -0
- package/dist/dto/request/id.dto.js.map +1 -0
- package/dist/dto/request/ids.dto.d.ts +3 -0
- package/dist/dto/request/ids.dto.js +28 -0
- package/dist/dto/request/ids.dto.js.map +1 -0
- package/dist/dto/request/index.d.ts +4 -0
- package/dist/dto/request/index.js +21 -0
- package/dist/dto/request/index.js.map +1 -0
- package/dist/dto/response/base-response-with-action-dates.dto.d.ts +7 -0
- package/dist/dto/response/base-response-with-action-dates.dto.js +36 -0
- package/dist/dto/response/base-response-with-action-dates.dto.js.map +1 -0
- package/dist/dto/response/base-response.dto.d.ts +4 -0
- package/dist/dto/response/base-response.dto.js +24 -0
- package/dist/dto/response/base-response.dto.js.map +1 -0
- package/dist/dto/response/error-response.dto.d.ts +8 -0
- package/dist/dto/response/error-response.dto.js +38 -0
- package/dist/dto/response/error-response.dto.js.map +1 -0
- package/dist/dto/response/index.d.ts +5 -0
- package/dist/dto/response/index.js +22 -0
- package/dist/dto/response/index.js.map +1 -0
- package/dist/dto/response/kafka-success-response.dto.d.ts +14 -0
- package/dist/dto/response/kafka-success-response.dto.js +66 -0
- package/dist/dto/response/kafka-success-response.dto.js.map +1 -0
- package/dist/dto/response/success-response.dto.d.ts +9 -0
- package/dist/dto/response/success-response.dto.js +44 -0
- package/dist/dto/response/success-response.dto.js.map +1 -0
- package/dist/dto/response/validation.dto.d.ts +25 -0
- package/dist/dto/response/validation.dto.js +84 -0
- package/dist/dto/response/validation.dto.js.map +1 -0
- package/dist/entities/action-dates.entity.d.ts +8 -0
- package/dist/entities/action-dates.entity.js +43 -0
- package/dist/entities/action-dates.entity.js.map +1 -0
- package/dist/entities/base.entity.d.ts +4 -0
- package/dist/entities/base.entity.js +22 -0
- package/dist/entities/base.entity.js.map +1 -0
- package/dist/entities/index.d.ts +2 -0
- package/dist/entities/index.js +19 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/parent.entity.d.ts +8 -0
- package/dist/entities/parent.entity.js +45 -0
- package/dist/entities/parent.entity.js.map +1 -0
- package/dist/enums/environments.enum.d.ts +6 -0
- package/dist/enums/environments.enum.js +11 -0
- package/dist/enums/environments.enum.js.map +1 -0
- package/dist/enums/index.d.ts +2 -0
- package/dist/enums/index.js +19 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/shared-messages.enum.d.ts +25 -0
- package/dist/enums/shared-messages.enum.js +30 -0
- package/dist/enums/shared-messages.enum.js.map +1 -0
- package/dist/filters/http-exception.filter.d.ts +8 -0
- package/dist/filters/http-exception.filter.js +65 -0
- package/dist/filters/http-exception.filter.js.map +1 -0
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +18 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/filters/rpc-exception.filter.d.ts +5 -0
- package/dist/filters/rpc-exception.filter.js +21 -0
- package/dist/filters/rpc-exception.filter.js.map +1 -0
- package/dist/helper/get-env.d.ts +1 -0
- package/dist/helper/get-env.helper.d.ts +1 -0
- package/dist/helper/get-env.helper.js +7 -0
- package/dist/helper/get-env.helper.js.map +1 -0
- package/dist/helper/get-env.js +7 -0
- package/dist/helper/get-env.js.map +1 -0
- package/dist/helper/index.d.ts +2 -0
- package/dist/helper/index.js +19 -0
- package/dist/helper/index.js.map +1 -0
- package/dist/helper/message-formatter.helper.d.ts +3 -0
- package/dist/helper/message-formatter.helper.js +27 -0
- package/dist/helper/message-formatter.helper.js.map +1 -0
- package/dist/helper/multi-inheritance.helper.d.ts +1 -0
- package/dist/helper/multi-inheritance.helper.js +13 -0
- package/dist/helper/multi-inheritance.helper.js.map +1 -0
- package/dist/helper/multi-inheritance.util.d.ts +1 -0
- package/dist/helper/multi-inheritance.util.js +13 -0
- package/dist/helper/multi-inheritance.util.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/interface/core-crud-service.option.d.ts +7 -0
- package/dist/interface/core-crud-service.option.js +10 -0
- package/dist/interface/core-crud-service.option.js.map +1 -0
- package/dist/interface/custom-validation-arguments.interface.d.ts +14 -0
- package/dist/interface/custom-validation-arguments.interface.js +3 -0
- package/dist/interface/custom-validation-arguments.interface.js.map +1 -0
- package/dist/interface/index.d.ts +2 -0
- package/dist/interface/index.js +19 -0
- package/dist/interface/index.js.map +1 -0
- package/dist/interface/kafka-success-response.interfase.d.ts +9 -0
- package/dist/interface/kafka-success-response.interfase.js +3 -0
- package/dist/interface/kafka-success-response.interfase.js.map +1 -0
- package/dist/interface/pagination-query.d.ts +13 -0
- package/dist/interface/pagination-query.js +55 -0
- package/dist/interface/pagination-query.js.map +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/kafka/constant/consumer.const.d.ts +12 -0
- package/dist/lib/kafka/constant/consumer.const.js +18 -0
- package/dist/lib/kafka/constant/consumer.const.js.map +1 -0
- package/dist/lib/kafka/constant/kafka.const.d.ts +9 -0
- package/dist/lib/kafka/constant/kafka.const.js +14 -0
- package/dist/lib/kafka/constant/kafka.const.js.map +1 -0
- package/dist/lib/kafka/index.d.ts +4 -0
- package/dist/lib/kafka/index.js +8 -0
- package/dist/lib/kafka/index.js.map +1 -0
- package/dist/lib/kafka/kafka-admin.service.d.ts +7 -0
- package/dist/lib/kafka/kafka-admin.service.js +47 -0
- package/dist/lib/kafka/kafka-admin.service.js.map +1 -0
- package/dist/lib/kafka/kafka-consumer.service.d.ts +9 -0
- package/dist/lib/kafka/kafka-consumer.service.js +50 -0
- package/dist/lib/kafka/kafka-consumer.service.js.map +1 -0
- package/dist/lib/kafka/kafka-instance.const.d.ts +2 -0
- package/dist/lib/kafka/kafka-instance.const.js +12 -0
- package/dist/lib/kafka/kafka-instance.const.js.map +1 -0
- package/dist/lib/kafka/kafka-logger.d.ts +2 -0
- package/dist/lib/kafka/kafka-logger.js +22 -0
- package/dist/lib/kafka/kafka-logger.js.map +1 -0
- package/dist/lib/kafka/kafka-producer.service.d.ts +10 -0
- package/dist/lib/kafka/kafka-producer.service.js +76 -0
- package/dist/lib/kafka/kafka-producer.service.js.map +1 -0
- package/dist/lib/kafka/kafka.interface.d.ts +15 -0
- package/dist/lib/kafka/kafka.interface.js +5 -0
- package/dist/lib/kafka/kafka.interface.js.map +1 -0
- package/dist/lib/kafka/kafka.module.d.ts +10 -0
- package/dist/lib/kafka/kafka.module.js +77 -0
- package/dist/lib/kafka/kafka.module.js.map +1 -0
- package/dist/lib/kafka/kafka.provider.d.ts +7 -0
- package/dist/lib/kafka/kafka.provider.js +12 -0
- package/dist/lib/kafka/kafka.provider.js.map +1 -0
- package/dist/lib/kafka/kafka.service.d.ts +38 -0
- package/dist/lib/kafka/kafka.service.js +124 -0
- package/dist/lib/kafka/kafka.service.js.map +1 -0
- package/dist/services/core-crud.service.d.ts +31 -0
- package/dist/services/core-crud.service.js +318 -0
- package/dist/services/core-crud.service.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +18 -0
- package/dist/services/index.js.map +1 -0
- package/dist/strategy/index.d.ts +1 -0
- package/dist/strategy/index.js +18 -0
- package/dist/strategy/index.js.map +1 -0
- package/dist/strategy/type-orm-naming.strategy.d.ts +4 -0
- package/dist/strategy/type-orm-naming.strategy.js +12 -0
- package/dist/strategy/type-orm-naming.strategy.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/validators/does-exist.validator.d.ts +8 -0
- package/dist/validators/does-exist.validator.js +48 -0
- package/dist/validators/does-exist.validator.js.map +1 -0
- package/dist/validators/env.validator.d.ts +2 -0
- package/dist/validators/env.validator.js +27 -0
- package/dist/validators/env.validator.js.map +1 -0
- package/dist/validators/index.d.ts +4 -0
- package/dist/validators/index.js +21 -0
- package/dist/validators/index.js.map +1 -0
- package/dist/validators/is-unique.validator.d.ts +7 -0
- package/dist/validators/is-unique.validator.js +58 -0
- package/dist/validators/is-unique.validator.js.map +1 -0
- package/dist/validators/validation-options.d.ts +3 -0
- package/dist/validators/validation-options.js +28 -0
- package/dist/validators/validation-options.js.map +1 -0
- package/nest-cli.json +8 -0
- package/package.json +81 -0
- package/tsconfig.build.json +4 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: '@typescript-eslint/parser',
|
|
3
|
+
parserOptions: {
|
|
4
|
+
project: 'tsconfig.json',
|
|
5
|
+
tsconfigRootDir: __dirname,
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
},
|
|
8
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
9
|
+
extends: [
|
|
10
|
+
'plugin:@typescript-eslint/recommended',
|
|
11
|
+
'plugin:prettier/recommended',
|
|
12
|
+
],
|
|
13
|
+
root: true,
|
|
14
|
+
env: {
|
|
15
|
+
node: true,
|
|
16
|
+
jest: true,
|
|
17
|
+
},
|
|
18
|
+
ignorePatterns: ['.eslintrc.js'],
|
|
19
|
+
rules: {
|
|
20
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
23
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Build and Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [created]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build-and-publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout repository
|
|
13
|
+
uses: actions/checkout@v3
|
|
14
|
+
|
|
15
|
+
- name: Set up Node.js
|
|
16
|
+
uses: actions/setup-node@v3
|
|
17
|
+
with:
|
|
18
|
+
node-version: '16' # Use the Node.js version your project requires
|
|
19
|
+
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: npm install
|
|
22
|
+
|
|
23
|
+
- name: Build project
|
|
24
|
+
run: npm run build # Adjust this if your build command is different
|
|
25
|
+
|
|
26
|
+
- name: Set NPM Token
|
|
27
|
+
run: npm config set _authToken=${{ secrets.NPM_TOKEN }}
|
|
28
|
+
env:
|
|
29
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
30
|
+
|
|
31
|
+
- name: Publish to npm
|
|
32
|
+
env:
|
|
33
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
34
|
+
run: npm publish --access public
|
package/.prettierrc
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Global, Module } from '@nestjs/common';
|
|
2
|
+
import { CachingService } from './caching.service';
|
|
3
|
+
import { CacheModule } from '@nestjs/cache-manager';
|
|
4
|
+
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
5
|
+
import * as redisStore from 'cache-manager-redis-store';
|
|
6
|
+
|
|
7
|
+
@Global()
|
|
8
|
+
@Module({
|
|
9
|
+
imports: [
|
|
10
|
+
CacheModule.register({
|
|
11
|
+
isGlobal: true,
|
|
12
|
+
imports: [ConfigModule],
|
|
13
|
+
useFactory: async (configService: ConfigService) => ({
|
|
14
|
+
ttl: configService.get('CACHE_TTL', 86400000),
|
|
15
|
+
store: redisStore,
|
|
16
|
+
host: configService.get('redis.host'),
|
|
17
|
+
port: configService.get('redis.port'),
|
|
18
|
+
password: configService.get('redis.password'),
|
|
19
|
+
max: 10000,
|
|
20
|
+
isGlobal: true,
|
|
21
|
+
}),
|
|
22
|
+
inject: [ConfigService],
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
providers: [CachingService],
|
|
26
|
+
exports: [CachingService],
|
|
27
|
+
})
|
|
28
|
+
export class CachingModule {}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
|
+
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
|
3
|
+
import { Cache } from 'cache-manager';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class CachingService {
|
|
7
|
+
constructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {}
|
|
8
|
+
|
|
9
|
+
getRedisClient() {
|
|
10
|
+
return this.cacheManager.store;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async get<T>(key: string) {
|
|
14
|
+
const result: string = await this.cacheManager.get<undefined | string>(key);
|
|
15
|
+
// JSON parse result
|
|
16
|
+
if (result) {
|
|
17
|
+
return JSON.parse(result) as T;
|
|
18
|
+
}
|
|
19
|
+
return result as T;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async set<T>(key: string, value: T, ttlSeconds: number): Promise<void> {
|
|
23
|
+
// stringify value
|
|
24
|
+
return await this.cacheManager.set(
|
|
25
|
+
key,
|
|
26
|
+
JSON.stringify(value),
|
|
27
|
+
ttlSeconds * 1000,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async del(key: string): Promise<void> {
|
|
32
|
+
return await this.cacheManager.del(key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validation-constraints.const';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class ValidationConstraints {
|
|
2
|
+
static readonly maxIntegerValue = 2147483646;
|
|
3
|
+
static readonly pageLimit = 50;
|
|
4
|
+
static readonly otpCodeLength = 6;
|
|
5
|
+
static readonly minSortFieldLength = 2;
|
|
6
|
+
static readonly maxSortFieldLength = 32;
|
|
7
|
+
static readonly shebaNumberLength = 26;
|
|
8
|
+
static readonly ticketMessageMinLength = 50;
|
|
9
|
+
static readonly ticketMessageMaxLength = 500;
|
|
10
|
+
static readonly trackingCodeLength = 8;
|
|
11
|
+
static readonly phonePattern = /^(?![1-9]).{11}$/;
|
|
12
|
+
static readonly faxPattern = /^\+?[0-9]{6,}$/;
|
|
13
|
+
static readonly postalCodeLength = 10;
|
|
14
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Get,
|
|
3
|
+
Post,
|
|
4
|
+
Body,
|
|
5
|
+
Put,
|
|
6
|
+
Param,
|
|
7
|
+
Delete,
|
|
8
|
+
NotFoundException,
|
|
9
|
+
HttpStatus,
|
|
10
|
+
BadRequestException,
|
|
11
|
+
} from '@nestjs/common';
|
|
12
|
+
import { Paginate, Paginated } from 'nestjs-paginate';
|
|
13
|
+
import { PaginateConfig } from 'nestjs-paginate/lib/paginate';
|
|
14
|
+
import { PaginationQueryCustom } from '../interface/pagination-query';
|
|
15
|
+
import { SharedMessages } from '../enums/shared-messages.enum';
|
|
16
|
+
import { SuccessResponse } from '../dto/response/success-response.dto';
|
|
17
|
+
import { BaseResponseWithActionDates } from '../dto/response/base-response-with-action-dates.dto';
|
|
18
|
+
import { IdDto } from '../dto/request/id.dto';
|
|
19
|
+
import { CoreCrudService } from '../services/core-crud.service';
|
|
20
|
+
import { ParentEntity } from '../entities/parent.entity';
|
|
21
|
+
|
|
22
|
+
export class CoreCrudController<
|
|
23
|
+
T extends ParentEntity,
|
|
24
|
+
CreateDto,
|
|
25
|
+
UpdateDto,
|
|
26
|
+
ResponseDto extends BaseResponseWithActionDates,
|
|
27
|
+
> {
|
|
28
|
+
protected constructor(
|
|
29
|
+
protected readonly coreService: CoreCrudService<T, CreateDto, UpdateDto>,
|
|
30
|
+
protected readonly responseDto: any,
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
async findAll(
|
|
34
|
+
@Paginate() query: PaginationQueryCustom,
|
|
35
|
+
paginateConfig: PaginateConfig<T>,
|
|
36
|
+
): Promise<Paginated<T>> {
|
|
37
|
+
const response = await this.coreService.findAllWithPagination(
|
|
38
|
+
query,
|
|
39
|
+
paginateConfig,
|
|
40
|
+
);
|
|
41
|
+
if (!response) throw new NotFoundException(SharedMessages.FETCH_FAILED);
|
|
42
|
+
|
|
43
|
+
response.data = response.data.map((item) => new this.responseDto(item));
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async findOneById(id: number): Promise<SuccessResponse<ResponseDto>> {
|
|
48
|
+
const response = await this.coreService.findOneById(id);
|
|
49
|
+
if (!response)
|
|
50
|
+
throw new NotFoundException(SharedMessages.RESOURCE_NOT_FOUND);
|
|
51
|
+
|
|
52
|
+
return new SuccessResponse<ResponseDto>(
|
|
53
|
+
new this.responseDto(response),
|
|
54
|
+
SharedMessages.SUCCESSFUL,
|
|
55
|
+
HttpStatus.OK,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async create(createDto: CreateDto): Promise<SuccessResponse<ResponseDto>> {
|
|
60
|
+
const response = await this.coreService.create(createDto);
|
|
61
|
+
if (!response) throw new BadRequestException(SharedMessages.CREATE_FAILED);
|
|
62
|
+
|
|
63
|
+
return new SuccessResponse<ResponseDto>(
|
|
64
|
+
new this.responseDto(response),
|
|
65
|
+
SharedMessages.SUCCESSFUL,
|
|
66
|
+
HttpStatus.CREATED,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async update(
|
|
71
|
+
{ id }: IdDto,
|
|
72
|
+
updateDto: UpdateDto,
|
|
73
|
+
): Promise<SuccessResponse<ResponseDto>> {
|
|
74
|
+
const response = await this.coreService.update(id, updateDto);
|
|
75
|
+
if (!response) throw new BadRequestException(SharedMessages.UPDATE_FAILED);
|
|
76
|
+
|
|
77
|
+
const foundItem = await this.coreService.findOneById(id);
|
|
78
|
+
return new SuccessResponse<ResponseDto>(
|
|
79
|
+
new this.responseDto(foundItem),
|
|
80
|
+
SharedMessages.SUCCESSFUL,
|
|
81
|
+
HttpStatus.OK,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async delete({ id }: IdDto): Promise<SuccessResponse<void>> {
|
|
86
|
+
const result = await this.coreService.deleteById(id);
|
|
87
|
+
if (!result) throw new BadRequestException(SharedMessages.DELETE_FAILED);
|
|
88
|
+
|
|
89
|
+
return new SuccessResponse<void>(
|
|
90
|
+
undefined,
|
|
91
|
+
SharedMessages.SUCCESSFUL,
|
|
92
|
+
HttpStatus.OK,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async softDelete({ id }: IdDto): Promise<SuccessResponse<void>> {
|
|
97
|
+
const result = await this.coreService.softDeleteById(id);
|
|
98
|
+
if (!result) throw new BadRequestException(SharedMessages.DELETE_FAILED);
|
|
99
|
+
|
|
100
|
+
return new SuccessResponse<void>(
|
|
101
|
+
undefined,
|
|
102
|
+
SharedMessages.SUCCESSFUL,
|
|
103
|
+
HttpStatus.OK,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './core-crud.controller';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const ORDER_KEY = Symbol.for('order_key');
|
|
2
|
+
export function Order(value: number): PropertyDecorator {
|
|
3
|
+
return (target, propertyKey) => {
|
|
4
|
+
Reflect.defineMetadata(ORDER_KEY, value, target, propertyKey);
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function getOrder(
|
|
9
|
+
target: unknown,
|
|
10
|
+
propertyKey: string | symbol,
|
|
11
|
+
defaultVal = 0,
|
|
12
|
+
) {
|
|
13
|
+
const result = Reflect.getMetadata(ORDER_KEY, target, propertyKey);
|
|
14
|
+
if (typeof result === 'number') {
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return defaultVal;
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { getSchemaPath } from '@nestjs/swagger';
|
|
3
|
+
import { SuccessResponse } from '../dto/response/success-response.dto';
|
|
4
|
+
import { ApiResponse } from '@nestjs/swagger';
|
|
5
|
+
|
|
6
|
+
export function CustomApiResponse(options: {
|
|
7
|
+
status: number;
|
|
8
|
+
description: string;
|
|
9
|
+
responseDto: any;
|
|
10
|
+
}) {
|
|
11
|
+
// Return a function that NestJS will call to apply the decorator
|
|
12
|
+
return function (target: any, key?: string, descriptor?: PropertyDescriptor) {
|
|
13
|
+
// Use applyDecorators to handle combining with other potential decorators
|
|
14
|
+
return applyDecorators(
|
|
15
|
+
ApiResponse({
|
|
16
|
+
status: options.status, // Typically CREATED status
|
|
17
|
+
description: options.description,
|
|
18
|
+
schema: {
|
|
19
|
+
$ref: getSchemaPath(SuccessResponse),
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
data: {
|
|
23
|
+
$ref: getSchemaPath(options.responseDto),
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
)(target, key, descriptor);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArrayMaxSize as arrayMaxSize } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function ArrayMaxSize(length: number): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
arrayMaxSize(length, {
|
|
6
|
+
message: 'validation.ARRAY_MAX_SIZE',
|
|
7
|
+
})(target, propertyKey);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArrayMinSize as arrayMinSize } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function ArrayMinSize(length: number): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
arrayMinSize(length, {
|
|
6
|
+
message: 'validation.ARRAY_MIN_SIZE',
|
|
7
|
+
})(target, propertyKey);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ArrayNotEmpty as arrayNotEmpty } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function ArrayNotEmpty(): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
arrayNotEmpty({ message: 'validation.NOT_EMPTY' })(target, propertyKey);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './is-string.decorator';
|
|
2
|
+
export * from './is-not-empty.decorator';
|
|
3
|
+
export * from './min-length.decorator';
|
|
4
|
+
export * from './max-length.decorator';
|
|
5
|
+
export * from './is-enum.decorator';
|
|
6
|
+
export * from './is-int.decorator';
|
|
7
|
+
export * from './is-positive.decorator';
|
|
8
|
+
export * from './min.decorator';
|
|
9
|
+
export * from './max.decorator';
|
|
10
|
+
export * from './is-array.decorator';
|
|
11
|
+
export * from './matches.decorator';
|
|
12
|
+
export * from './is-number-string.decorator';
|
|
13
|
+
export * from './is-boolean.decorator';
|
|
14
|
+
export * from './is-uuid.decorator';
|
|
15
|
+
export * from './is-object.decorator';
|
|
16
|
+
export * from './is-date.decorator';
|
|
17
|
+
export * from './array-not-empty.decorator';
|
|
18
|
+
export * from './array-min-size.decorator';
|
|
19
|
+
export * from './array-max-size.decorator';
|
|
20
|
+
export * from './is-not-empty-object.decorator';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IsBoolean as isBoolean } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsBoolean(options?: { each?: boolean }): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
isBoolean(Object.assign({ message: 'validation.BOOLEAN' }, options))(
|
|
6
|
+
target,
|
|
7
|
+
propertyKey,
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IsDate as isDate } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsDate(options?: { each?: boolean }): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
isDate(Object.assign({ message: 'validation.DATE' }, options))(
|
|
6
|
+
target,
|
|
7
|
+
propertyKey,
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IsEnum as isEnum } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsEnum(value: any): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
isEnum(value, {
|
|
6
|
+
message: 'validation.ENUM',
|
|
7
|
+
})(target, propertyKey);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IsInt as isInt } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsInt(options?: { each?: boolean }): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
isInt(Object.assign({ message: 'validation.INT' }, options))(
|
|
6
|
+
target,
|
|
7
|
+
propertyKey,
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IsNotEmptyObject as isNotEmptyObject } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsNotEmptyObject(
|
|
4
|
+
params: {
|
|
5
|
+
nullable?: boolean;
|
|
6
|
+
},
|
|
7
|
+
options?: { each?: boolean },
|
|
8
|
+
): PropertyDecorator {
|
|
9
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
10
|
+
isNotEmptyObject(params, {
|
|
11
|
+
...options,
|
|
12
|
+
message: 'validation.IS_NOT_EMPTY_OBJECT',
|
|
13
|
+
})(target, propertyKey);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IsNumberString as isNumberString } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsNumberString(options?: {
|
|
4
|
+
each?: boolean;
|
|
5
|
+
}): PropertyDecorator {
|
|
6
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
7
|
+
isNumberString(
|
|
8
|
+
{},
|
|
9
|
+
Object.assign({ message: 'validation.NUMBER_STRING' }, options),
|
|
10
|
+
)(target, propertyKey);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ValidationOptions, IsObject as isObject } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsObject(options?: ValidationOptions): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
isObject({ ...options, message: 'validation.OBJECT' })(target, propertyKey);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IsPositive as isPositive } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsPositive(options?: { each?: boolean }): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
isPositive(Object.assign({ message: 'validation.POSITIVE' }, options))(
|
|
6
|
+
target,
|
|
7
|
+
propertyKey,
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IsString as isString } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function IsString(options?: { each?: boolean }): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
const each = (options && options.each) || false;
|
|
6
|
+
isString({ each, message: 'validation.STRING' })(target, propertyKey);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Matches as matches } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function Matches(
|
|
4
|
+
pattern,
|
|
5
|
+
options?: { each?: boolean },
|
|
6
|
+
): PropertyDecorator {
|
|
7
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
8
|
+
matches(pattern, Object.assign({ message: 'validation.PATTERN' }, options))(
|
|
9
|
+
target,
|
|
10
|
+
propertyKey,
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MaxLength as maxLength } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function MaxLength(length: number): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
maxLength(length, {
|
|
6
|
+
message: 'validation.MAX_LENGTH',
|
|
7
|
+
})(target, propertyKey);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Max as max } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function Max(
|
|
4
|
+
value: number,
|
|
5
|
+
options?: { each?: boolean },
|
|
6
|
+
): PropertyDecorator {
|
|
7
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
8
|
+
max(value, Object.assign({ message: 'validation.MAX' }, options))(
|
|
9
|
+
target,
|
|
10
|
+
propertyKey,
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MinLength as minLength } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function MinLength(length: number): PropertyDecorator {
|
|
4
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
5
|
+
minLength(length, {
|
|
6
|
+
message: 'validation.MIN_LENGTH',
|
|
7
|
+
})(target, propertyKey);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Min as min } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export function Min(
|
|
4
|
+
value: number,
|
|
5
|
+
options?: { each?: boolean },
|
|
6
|
+
): PropertyDecorator {
|
|
7
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
8
|
+
min(value, Object.assign({ message: 'validation.MIN' }, options))(
|
|
9
|
+
target,
|
|
10
|
+
propertyKey,
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IsOptional } from 'class-validator';
|
|
2
|
+
import { IsInt, IsNotEmpty, IsPositive, Max } from './default';
|
|
3
|
+
import { ValidationConstraints } from '../../constants/validation-constraints.const';
|
|
4
|
+
|
|
5
|
+
export function IsId(options?: {
|
|
6
|
+
optional?: boolean;
|
|
7
|
+
each?: boolean;
|
|
8
|
+
}): PropertyDecorator {
|
|
9
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
10
|
+
const each = (options && options.each) || false;
|
|
11
|
+
IsInt({ each })(target, propertyKey);
|
|
12
|
+
IsPositive({ each })(target, propertyKey);
|
|
13
|
+
Max(ValidationConstraints.maxIntegerValue, {
|
|
14
|
+
each,
|
|
15
|
+
})(target, propertyKey);
|
|
16
|
+
|
|
17
|
+
if (options && options.optional) IsOptional()(target, propertyKey);
|
|
18
|
+
else IsNotEmpty()(target, propertyKey);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IsOptional } from 'class-validator';
|
|
2
|
+
import { IsNotEmpty, IsString } from './default';
|
|
3
|
+
|
|
4
|
+
export function CustomIsString(options?: {
|
|
5
|
+
each?: boolean;
|
|
6
|
+
optional: boolean;
|
|
7
|
+
}): PropertyDecorator {
|
|
8
|
+
return function (target: any, propertyKey: string | symbol): void {
|
|
9
|
+
IsString({ each: options ? options.each : false })(target, propertyKey);
|
|
10
|
+
|
|
11
|
+
if (options && options.optional) IsOptional()(target, propertyKey);
|
|
12
|
+
else IsNotEmpty()(target, propertyKey);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IsNumber, IsOptional, IsString } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class EventDto<T> {
|
|
4
|
+
@IsString()
|
|
5
|
+
@IsOptional()
|
|
6
|
+
topic?: string;
|
|
7
|
+
|
|
8
|
+
@IsString()
|
|
9
|
+
event_source: string;
|
|
10
|
+
|
|
11
|
+
@IsString()
|
|
12
|
+
@IsOptional()
|
|
13
|
+
model?: string;
|
|
14
|
+
|
|
15
|
+
@IsString()
|
|
16
|
+
@IsOptional()
|
|
17
|
+
event_key?: string;
|
|
18
|
+
|
|
19
|
+
@IsOptional()
|
|
20
|
+
data?: T;
|
|
21
|
+
|
|
22
|
+
@IsNumber()
|
|
23
|
+
@IsOptional()
|
|
24
|
+
partition?: number;
|
|
25
|
+
}
|