@nest-omni/core 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/README +16 -0
  2. package/dist/boilerplate.polyfill.js.map +1 -1
  3. package/dist/common/abstract-client.service.js.map +1 -1
  4. package/dist/common/abstract.entity.js.map +1 -1
  5. package/dist/common/dto/abstract.dto.js.map +1 -1
  6. package/dist/common/utils.js.map +1 -1
  7. package/dist/decorators/auth-user.decorator.js.map +1 -1
  8. package/dist/decorators/field.decorators.js.map +1 -1
  9. package/dist/decorators/omni-auth.decorator.js.map +1 -1
  10. package/dist/decorators/swagger.schema.js.map +1 -1
  11. package/dist/decorators/transform.decorators.js.map +1 -1
  12. package/dist/decorators/user-check.decorator.js.map +1 -1
  13. package/dist/decorators/user.decorator.js.map +1 -1
  14. package/dist/filters/bad-request.filter.js.map +1 -1
  15. package/dist/health-checker/health-checker.controller.js.map +1 -1
  16. package/dist/health-checker/health-indicators/service.indicator.js.map +1 -1
  17. package/dist/helpers/common.helper.js.map +1 -1
  18. package/dist/helpers/date.helper.js.map +1 -1
  19. package/dist/interceptors/language-interceptor.service.js.map +1 -1
  20. package/dist/interceptors/translation-interceptor.service.js.map +1 -1
  21. package/dist/middlewares/request-id.middleware.js.map +1 -1
  22. package/dist/providers/context.provider.js.map +1 -1
  23. package/dist/providers/generator.provider.js.map +1 -1
  24. package/dist/setup/bootstrap.setup.js.map +1 -1
  25. package/dist/setup-swagger.js.map +1 -1
  26. package/dist/shared/serviceRegistryModule.js.map +1 -1
  27. package/dist/shared/services/api-config.service.js.map +1 -1
  28. package/dist/shared/services/translation.service.js.map +1 -1
  29. package/dist/snake-naming.strategy.js.map +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/dist/validators/file-mimetype.validator.js.map +1 -1
  32. package/dist/validators/is-unique.validator.js.map +1 -1
  33. package/dist/validators/skip-empty.validator.js.map +1 -1
  34. package/package.json +11 -7
  35. package/dist/guards/auth.guard.d.ts +0 -4
  36. package/dist/guards/auth.guard.js +0 -13
  37. package/dist/guards/auth.guard.js.map +0 -1
  38. package/dist/guards/roles.guard.d.ts +0 -7
  39. package/dist/guards/roles.guard.js +0 -36
  40. package/dist/guards/roles.guard.js.map +0 -1
  41. package/dist/helpers/excel.helper.d.ts +0 -12
  42. package/dist/helpers/excel.helper.js +0 -250
  43. package/dist/helpers/excel.helper.js.map +0 -1
  44. package/src/boilerplate.polyfill.d.ts +0 -39
  45. package/src/boilerplate.polyfill.js +0 -78
  46. package/src/boilerplate.polyfill.ts +0 -202
  47. package/src/common/abstract-client.service.d.ts +0 -20
  48. package/src/common/abstract-client.service.js +0 -39
  49. package/src/common/abstract-client.service.ts +0 -56
  50. package/src/common/abstract.entity.d.ts +0 -24
  51. package/src/common/abstract.entity.js +0 -152
  52. package/src/common/abstract.entity.ts +0 -73
  53. package/src/common/dto/abstract.dto.d.ts +0 -13
  54. package/src/common/dto/abstract.dto.js +0 -96
  55. package/src/common/dto/abstract.dto.ts +0 -64
  56. package/src/common/dto/bulk-id.dto.d.ts +0 -3
  57. package/src/common/dto/bulk-id.dto.js +0 -63
  58. package/src/common/dto/bulk-id.dto.ts +0 -13
  59. package/src/common/dto/create-translation.dto.d.ts +0 -5
  60. package/src/common/dto/create-translation.dto.js +0 -63
  61. package/src/common/dto/create-translation.dto.ts +0 -10
  62. package/src/common/dto/page-meta.dto.d.ts +0 -15
  63. package/src/common/dto/page-meta.dto.js +0 -88
  64. package/src/common/dto/page-meta.dto.ts +0 -37
  65. package/src/common/dto/page-options.dto.d.ts +0 -8
  66. package/src/common/dto/page-options.dto.js +0 -87
  67. package/src/common/dto/page-options.dto.ts +0 -35
  68. package/src/common/dto/page.dto.d.ts +0 -11
  69. package/src/common/dto/page.dto.js +0 -94
  70. package/src/common/dto/page.dto.ts +0 -36
  71. package/src/common/utils.d.ts +0 -14
  72. package/src/common/utils.js +0 -39
  73. package/src/common/utils.ts +0 -45
  74. package/src/constants/index.d.ts +0 -4
  75. package/src/constants/index.js +0 -20
  76. package/src/constants/index.ts +0 -4
  77. package/src/constants/language-code.d.ts +0 -5
  78. package/src/constants/language-code.js +0 -10
  79. package/src/constants/language-code.ts +0 -7
  80. package/src/constants/order.d.ts +0 -4
  81. package/src/constants/order.js +0 -8
  82. package/src/constants/order.ts +0 -4
  83. package/src/constants/role-type.d.ts +0 -4
  84. package/src/constants/role-type.js +0 -8
  85. package/src/constants/role-type.ts +0 -4
  86. package/src/constants/token-type.d.ts +0 -4
  87. package/src/constants/token-type.js +0 -8
  88. package/src/constants/token-type.ts +0 -4
  89. package/src/decorators/api-page-ok-response.decorator.d.ts +0 -5
  90. package/src/decorators/api-page-ok-response.decorator.js +0 -25
  91. package/src/decorators/api-page-ok-response.decorator.ts +0 -31
  92. package/src/decorators/auth-user.decorator.d.ts +0 -1
  93. package/src/decorators/auth-user.decorator.js +0 -15
  94. package/src/decorators/auth-user.decorator.ts +0 -16
  95. package/src/decorators/controller.decorator.d.ts +0 -1
  96. package/src/decorators/controller.decorator.js +0 -34
  97. package/src/decorators/controller.decorator.ts +0 -8
  98. package/src/decorators/field.decorators.d.ts +0 -71
  99. package/src/decorators/field.decorators.js +0 -455
  100. package/src/decorators/field.decorators.ts +0 -773
  101. package/src/decorators/http.decorators.d.ts +0 -3
  102. package/src/decorators/http.decorators.js +0 -8
  103. package/src/decorators/http.decorators.ts +0 -10
  104. package/src/decorators/index.d.ts +0 -12
  105. package/src/decorators/index.js +0 -28
  106. package/src/decorators/index.ts +0 -12
  107. package/src/decorators/omni-auth.decorator.d.ts +0 -8
  108. package/src/decorators/omni-auth.decorator.js +0 -60
  109. package/src/decorators/omni-auth.decorator.ts +0 -46
  110. package/src/decorators/operation.decorator.d.ts +0 -1
  111. package/src/decorators/operation.decorator.js +0 -6
  112. package/src/decorators/operation.decorator.ts +0 -4
  113. package/src/decorators/property.decorators.d.ts +0 -15
  114. package/src/decorators/property.decorators.js +0 -36
  115. package/src/decorators/property.decorators.ts +0 -62
  116. package/src/decorators/public-route.decorator.d.ts +0 -3
  117. package/src/decorators/public-route.decorator.js +0 -8
  118. package/src/decorators/public-route.decorator.ts +0 -8
  119. package/src/decorators/swagger.schema.d.ts +0 -5
  120. package/src/decorators/swagger.schema.js +0 -82
  121. package/src/decorators/swagger.schema.ts +0 -117
  122. package/src/decorators/timestamp-column.decorator.d.ts +0 -1
  123. package/src/decorators/timestamp-column.decorator.js +0 -28
  124. package/src/decorators/timestamp-column.decorator.ts +0 -29
  125. package/src/decorators/transform.decorators.d.ts +0 -35
  126. package/src/decorators/transform.decorators.js +0 -122
  127. package/src/decorators/transform.decorators.ts +0 -147
  128. package/src/decorators/translate.decorator.d.ts +0 -5
  129. package/src/decorators/translate.decorator.js +0 -18
  130. package/src/decorators/translate.decorator.ts +0 -19
  131. package/src/decorators/use-dto.decorator.d.ts +0 -4
  132. package/src/decorators/use-dto.decorator.js +0 -9
  133. package/src/decorators/use-dto.decorator.ts +0 -11
  134. package/src/decorators/user-check.decorator.d.ts +0 -6
  135. package/src/decorators/user-check.decorator.js +0 -44
  136. package/src/decorators/user-check.decorator.ts +0 -30
  137. package/src/decorators/user.decorator.d.ts +0 -8
  138. package/src/decorators/user.decorator.js +0 -62
  139. package/src/decorators/user.decorator.ts +0 -48
  140. package/src/decorators/user_auth.decorator.d.ts +0 -1
  141. package/src/decorators/user_auth.decorator.js +0 -16
  142. package/src/decorators/user_auth.decorator.ts +0 -15
  143. package/src/decorators/validator.decorators.d.ts +0 -10
  144. package/src/decorators/validator.decorators.js +0 -59
  145. package/src/decorators/validator.decorators.ts +0 -78
  146. package/src/exceptions/file-not-image.exception.d.ts +0 -4
  147. package/src/exceptions/file-not-image.exception.js +0 -10
  148. package/src/exceptions/file-not-image.exception.ts +0 -7
  149. package/src/exceptions/index.d.ts +0 -2
  150. package/src/exceptions/index.js +0 -18
  151. package/src/exceptions/index.ts +0 -2
  152. package/src/exceptions/page-type.exception.d.ts +0 -4
  153. package/src/exceptions/page-type.exception.js +0 -10
  154. package/src/exceptions/page-type.exception.ts +0 -7
  155. package/src/exceptions/user-not-found.exception.d.ts +0 -4
  156. package/src/exceptions/user-not-found.exception.js +0 -10
  157. package/src/exceptions/user-not-found.exception.ts +0 -7
  158. package/src/filters/bad-request.filter.d.ts +0 -5
  159. package/src/filters/bad-request.filter.js +0 -104
  160. package/src/filters/bad-request.filter.ts +0 -67
  161. package/src/filters/constraint-errors.d.ts +0 -1
  162. package/src/filters/constraint-errors.js +0 -7
  163. package/src/filters/constraint-errors.ts +0 -5
  164. package/src/filters/index.d.ts +0 -3
  165. package/src/filters/index.js +0 -19
  166. package/src/filters/index.ts +0 -3
  167. package/src/filters/query-failed.filter.d.ts +0 -10
  168. package/src/filters/query-failed.filter.js +0 -81
  169. package/src/filters/query-failed.filter.ts +0 -32
  170. package/src/health-checker/health-checker.controller.d.ts +0 -15
  171. package/src/health-checker/health-checker.controller.js +0 -104
  172. package/src/health-checker/health-checker.controller.ts +0 -51
  173. package/src/health-checker/health-checker.module.d.ts +0 -2
  174. package/src/health-checker/health-checker.module.js +0 -69
  175. package/src/health-checker/health-checker.module.ts +0 -13
  176. package/src/health-checker/health-indicators/service.indicator.d.ts +0 -8
  177. package/src/health-checker/health-indicators/service.indicator.js +0 -102
  178. package/src/health-checker/health-indicators/service.indicator.ts +0 -44
  179. package/src/helpers/common.helper.d.ts +0 -16
  180. package/src/helpers/common.helper.js +0 -49
  181. package/src/helpers/common.helper.ts +0 -49
  182. package/src/helpers/date.helper.d.ts +0 -10
  183. package/src/helpers/date.helper.js +0 -81
  184. package/src/helpers/date.helper.ts +0 -64
  185. package/src/helpers/excel.helper.d.ts +0 -27
  186. package/src/helpers/excel.helper.js +0 -338
  187. package/src/helpers/index.d.ts +0 -3
  188. package/src/helpers/index.js +0 -19
  189. package/src/helpers/index.ts +0 -3
  190. package/src/i18n/en_US/validation.json +0 -38
  191. package/src/i18n/zh_CN/validation.json +0 -38
  192. package/src/index.d.ts +0 -11
  193. package/src/index.js +0 -28
  194. package/src/index.ts +0 -12
  195. package/src/interceptors/auth-user.interceptor.d.ts +0 -4
  196. package/src/interceptors/auth-user.interceptor.js +0 -68
  197. package/src/interceptors/auth-user.interceptor.ts +0 -20
  198. package/src/interceptors/index.d.ts +0 -2
  199. package/src/interceptors/index.js +0 -18
  200. package/src/interceptors/index.ts +0 -2
  201. package/src/interceptors/language-interceptor.service.d.ts +0 -6
  202. package/src/interceptors/language-interceptor.service.js +0 -74
  203. package/src/interceptors/language-interceptor.service.ts +0 -31
  204. package/src/interceptors/translation-interceptor.service.d.ts +0 -5
  205. package/src/interceptors/translation-interceptor.service.js +0 -83
  206. package/src/interceptors/translation-interceptor.service.ts +0 -43
  207. package/src/interfaces/IApiFile.d.ts +0 -4
  208. package/src/interfaces/IApiFile.js +0 -2
  209. package/src/interfaces/IApiFile.ts +0 -4
  210. package/src/interfaces/IFile.d.ts +0 -9
  211. package/src/interfaces/IFile.js +0 -2
  212. package/src/interfaces/IFile.ts +0 -8
  213. package/src/interfaces/ITranslationDecoratorInterface.d.ts +0 -3
  214. package/src/interfaces/ITranslationDecoratorInterface.js +0 -2
  215. package/src/interfaces/ITranslationDecoratorInterface.ts +0 -3
  216. package/src/interfaces/index.d.ts +0 -3
  217. package/src/interfaces/index.js +0 -19
  218. package/src/interfaces/index.ts +0 -3
  219. package/src/interfaces/response.d.ts +0 -25
  220. package/src/interfaces/response.js +0 -2
  221. package/src/interfaces/response.ts +0 -37
  222. package/src/middlewares/index.d.ts +0 -3
  223. package/src/middlewares/index.js +0 -19
  224. package/src/middlewares/index.ts +0 -3
  225. package/src/middlewares/omni-auth.middleware.d.ts +0 -1
  226. package/src/middlewares/omni-auth.middleware.js +0 -13
  227. package/src/middlewares/omni-auth.middleware.ts +0 -10
  228. package/src/middlewares/powerby.middleware.d.ts +0 -1
  229. package/src/middlewares/powerby.middleware.js +0 -10
  230. package/src/middlewares/powerby.middleware.ts +0 -6
  231. package/src/middlewares/request-id.middleware.d.ts +0 -7
  232. package/src/middlewares/request-id.middleware.js +0 -22
  233. package/src/middlewares/request-id.middleware.ts +0 -28
  234. package/src/providers/context.provider.d.ts +0 -32
  235. package/src/providers/context.provider.js +0 -73
  236. package/src/providers/context.provider.ts +0 -98
  237. package/src/providers/generator.provider.d.ts +0 -13
  238. package/src/providers/generator.provider.js +0 -54
  239. package/src/providers/generator.provider.ts +0 -66
  240. package/src/providers/index.d.ts +0 -2
  241. package/src/providers/index.js +0 -18
  242. package/src/providers/index.ts +0 -2
  243. package/src/setup/bootstrap.setup.d.ts +0 -5
  244. package/src/setup/bootstrap.setup.js +0 -138
  245. package/src/setup/bootstrap.setup.ts +0 -139
  246. package/src/setup/index.d.ts +0 -1
  247. package/src/setup/index.js +0 -17
  248. package/src/setup/index.ts +0 -1
  249. package/src/setup/microservices.setup.js +0 -55
  250. package/src/setup-swagger.d.ts +0 -2
  251. package/src/setup-swagger.js +0 -62
  252. package/src/setup-swagger.ts +0 -67
  253. package/src/shared/index.d.ts +0 -2
  254. package/src/shared/index.js +0 -18
  255. package/src/shared/index.ts +0 -2
  256. package/src/shared/serviceRegistryModule.d.ts +0 -2
  257. package/src/shared/serviceRegistryModule.js +0 -176
  258. package/src/shared/serviceRegistryModule.ts +0 -110
  259. package/src/shared/services/api-config.service.d.ts +0 -73
  260. package/src/shared/services/api-config.service.js +0 -335
  261. package/src/shared/services/api-config.service.ts +0 -319
  262. package/src/shared/services/aws-s3.service.d.ts +0 -10
  263. package/src/shared/services/aws-s3.service.js +0 -96
  264. package/src/shared/services/aws-s3.service.ts +0 -39
  265. package/src/shared/services/generator.service.d.ts +0 -4
  266. package/src/shared/services/generator.service.js +0 -67
  267. package/src/shared/services/generator.service.ts +0 -13
  268. package/src/shared/services/index.d.ts +0 -5
  269. package/src/shared/services/index.js +0 -21
  270. package/src/shared/services/index.ts +0 -5
  271. package/src/shared/services/translation.service.d.ts +0 -9
  272. package/src/shared/services/translation.service.js +0 -109
  273. package/src/shared/services/translation.service.ts +0 -59
  274. package/src/shared/services/validator.service.d.ts +0 -3
  275. package/src/shared/services/validator.service.js +0 -64
  276. package/src/shared/services/validator.service.ts +0 -10
  277. package/src/snake-naming.strategy.d.ts +0 -11
  278. package/src/snake-naming.strategy.js +0 -37
  279. package/src/snake-naming.strategy.ts +0 -64
  280. package/src/types.d.ts +0 -9
  281. package/src/types.js +0 -2
  282. package/src/types.ts +0 -44
  283. package/src/validators/file-mimetype.validator.d.ts +0 -13
  284. package/src/validators/file-mimetype.validator.js +0 -21
  285. package/src/validators/file-mimetype.validator.ts +0 -34
  286. package/src/validators/index.d.ts +0 -3
  287. package/src/validators/index.js +0 -19
  288. package/src/validators/index.ts +0 -3
  289. package/src/validators/is-exists.validator.d.ts +0 -18
  290. package/src/validators/is-exists.validator.js +0 -99
  291. package/src/validators/is-exists.validator.ts +0 -60
  292. package/src/validators/is-unique.validator.d.ts +0 -17
  293. package/src/validators/is-unique.validator.js +0 -131
  294. package/src/validators/is-unique.validator.ts +0 -93
  295. package/src/validators/phone-country-code.validator.d.ts +0 -2
  296. package/src/validators/phone-country-code.validator.js +0 -30
  297. package/src/validators/phone-country-code.validator.ts +0 -36
  298. package/src/validators/same-as.validator.d.ts +0 -2
  299. package/src/validators/same-as.validator.js +0 -25
  300. package/src/validators/same-as.validator.ts +0 -27
  301. package/src/validators/skip-empty.validator.d.ts +0 -6
  302. package/src/validators/skip-empty.validator.js +0 -23
  303. package/src/validators/skip-empty.validator.ts +0 -25
  304. package/tsconfig.json +0 -21
  305. package/tsconfig.lib.json +0 -16
@@ -1,104 +0,0 @@
1
- "use strict";
2
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
- var useValue = arguments.length > 2;
4
- for (var i = 0; i < initializers.length; i++) {
5
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6
- }
7
- return useValue ? value : void 0;
8
- };
9
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
10
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
11
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
12
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
14
- var _, done = false;
15
- for (var i = decorators.length - 1; i >= 0; i--) {
16
- var context = {};
17
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
18
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
19
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
20
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21
- if (kind === "accessor") {
22
- if (result === void 0) continue;
23
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24
- if (_ = accept(result.get)) descriptor.get = _;
25
- if (_ = accept(result.set)) descriptor.set = _;
26
- if (_ = accept(result.init)) initializers.unshift(_);
27
- }
28
- else if (_ = accept(result)) {
29
- if (kind === "field") initializers.unshift(_);
30
- else descriptor[key] = _;
31
- }
32
- }
33
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
- done = true;
35
- };
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
46
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
47
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.HealthCheckerController = void 0;
54
- const ioredis_1 = __importDefault(require("ioredis"));
55
- const common_1 = require("@nestjs/common");
56
- const terminus_1 = require("@nestjs/terminus");
57
- const swagger_1 = require("@nestjs/swagger");
58
- let HealthCheckerController = (() => {
59
- let _classDecorators = [(0, common_1.Controller)('health')];
60
- let _classDescriptor;
61
- let _classExtraInitializers = [];
62
- let _classThis;
63
- let _instanceExtraInitializers = [];
64
- let _check_decorators;
65
- var HealthCheckerController = _classThis = class {
66
- constructor(configService, healthCheckService, ormIndicator, serviceIndicator, redisIndicator) {
67
- this.configService = (__runInitializers(this, _instanceExtraInitializers), configService);
68
- this.healthCheckService = healthCheckService;
69
- this.ormIndicator = ormIndicator;
70
- this.serviceIndicator = serviceIndicator;
71
- this.redisIndicator = redisIndicator;
72
- if (this.configService.isRedisEnabled) {
73
- this.redis = new ioredis_1.default(this.configService.ioRedisConfig);
74
- }
75
- }
76
- check() {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- const indicator = [
79
- () => this.ormIndicator.pingCheck('database', { timeout: 1500 }),
80
- ];
81
- if (this.configService.isRedisEnabled) {
82
- indicator.push(() => this.redisIndicator.checkHealth('redis', {
83
- type: 'redis',
84
- client: this.redis,
85
- timeout: 1500,
86
- }));
87
- }
88
- return this.healthCheckService.check(indicator);
89
- });
90
- }
91
- };
92
- __setFunctionName(_classThis, "HealthCheckerController");
93
- (() => {
94
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
95
- _check_decorators = [(0, common_1.Get)(), (0, terminus_1.HealthCheck)(), (0, swagger_1.ApiOperation)({ summary: 'Service health check' })];
96
- __esDecorate(_classThis, null, _check_decorators, { kind: "method", name: "check", static: false, private: false, access: { has: obj => "check" in obj, get: obj => obj.check }, metadata: _metadata }, null, _instanceExtraInitializers);
97
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
98
- HealthCheckerController = _classThis = _classDescriptor.value;
99
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
100
- __runInitializers(_classThis, _classExtraInitializers);
101
- })();
102
- return HealthCheckerController = _classThis;
103
- })();
104
- exports.HealthCheckerController = HealthCheckerController;
@@ -1,51 +0,0 @@
1
- import Redis from 'ioredis';
2
- import { Controller, Get } from '@nestjs/common';
3
- import type { HealthCheckResult } from '@nestjs/terminus';
4
- import {
5
- HealthCheck,
6
- HealthCheckService,
7
- TypeOrmHealthIndicator,
8
- } from '@nestjs/terminus';
9
-
10
- import { ServiceHealthIndicator } from './health-indicators/service.indicator';
11
- import { ApiOperation } from '@nestjs/swagger';
12
- import { RedisHealthIndicator } from '@liaoliaots/nestjs-redis-health';
13
- import { ApiConfigService } from '../shared/services';
14
-
15
- @Controller('health')
16
- export class HealthCheckerController {
17
- private readonly redis: Redis;
18
-
19
- constructor(
20
- private configService: ApiConfigService,
21
- private healthCheckService: HealthCheckService,
22
- private ormIndicator: TypeOrmHealthIndicator,
23
- private serviceIndicator: ServiceHealthIndicator,
24
- private redisIndicator: RedisHealthIndicator,
25
- ) {
26
- if (this.configService.isRedisEnabled) {
27
- this.redis = new Redis(this.configService.ioRedisConfig);
28
- }
29
- }
30
-
31
- @Get()
32
- @HealthCheck()
33
- @ApiOperation({ summary: 'Service health check' })
34
- async check(): Promise<HealthCheckResult> {
35
- const indicator = [
36
- () => this.ormIndicator.pingCheck('database', { timeout: 1500 }),
37
- ];
38
-
39
- if (this.configService.isRedisEnabled) {
40
- indicator.push(() =>
41
- this.redisIndicator.checkHealth('redis', {
42
- type: 'redis',
43
- client: this.redis,
44
- timeout: 1500,
45
- }),
46
- );
47
- }
48
-
49
- return this.healthCheckService.check(indicator);
50
- }
51
- }
@@ -1,2 +0,0 @@
1
- export declare class HealthCheckerModule {
2
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
- };
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.HealthCheckerModule = void 0;
42
- const common_1 = require("@nestjs/common");
43
- const terminus_1 = require("@nestjs/terminus");
44
- const nestjs_redis_health_1 = require("@liaoliaots/nestjs-redis-health");
45
- const health_checker_controller_1 = require("./health-checker.controller");
46
- const service_indicator_1 = require("./health-indicators/service.indicator");
47
- const services_1 = require("../shared/services");
48
- let HealthCheckerModule = (() => {
49
- let _classDecorators = [(0, common_1.Module)({
50
- imports: [terminus_1.TerminusModule, nestjs_redis_health_1.RedisHealthModule],
51
- controllers: [health_checker_controller_1.HealthCheckerController],
52
- providers: [services_1.ApiConfigService, service_indicator_1.ServiceHealthIndicator],
53
- })];
54
- let _classDescriptor;
55
- let _classExtraInitializers = [];
56
- let _classThis;
57
- var HealthCheckerModule = _classThis = class {
58
- };
59
- __setFunctionName(_classThis, "HealthCheckerModule");
60
- (() => {
61
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
62
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
63
- HealthCheckerModule = _classThis = _classDescriptor.value;
64
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
65
- __runInitializers(_classThis, _classExtraInitializers);
66
- })();
67
- return HealthCheckerModule = _classThis;
68
- })();
69
- exports.HealthCheckerModule = HealthCheckerModule;
@@ -1,13 +0,0 @@
1
- import { Module } from '@nestjs/common';
2
- import { TerminusModule } from '@nestjs/terminus';
3
- import { RedisHealthModule } from '@liaoliaots/nestjs-redis-health';
4
- import { HealthCheckerController } from './health-checker.controller';
5
- import { ServiceHealthIndicator } from './health-indicators/service.indicator';
6
- import { ApiConfigService } from '../shared/services';
7
-
8
- @Module({
9
- imports: [TerminusModule, RedisHealthModule],
10
- controllers: [HealthCheckerController],
11
- providers: [ApiConfigService, ServiceHealthIndicator],
12
- })
13
- export class HealthCheckerModule {}
@@ -1,8 +0,0 @@
1
- import { ClientProxy } from '@nestjs/microservices';
2
- import type { HealthIndicatorResult } from '@nestjs/terminus';
3
- import { HealthIndicator } from '@nestjs/terminus';
4
- export declare class ServiceHealthIndicator extends HealthIndicator {
5
- private readonly clientProxy?;
6
- constructor(clientProxy?: ClientProxy);
7
- isHealthy(eventName: string): Promise<HealthIndicatorResult>;
8
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
46
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
47
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.ServiceHealthIndicator = void 0;
51
- const common_1 = require("@nestjs/common");
52
- const terminus_1 = require("@nestjs/terminus");
53
- const rxjs_1 = require("rxjs");
54
- const operators_1 = require("rxjs/operators");
55
- let ServiceHealthIndicator = (() => {
56
- let _classDecorators = [(0, common_1.Injectable)()];
57
- let _classDescriptor;
58
- let _classExtraInitializers = [];
59
- let _classThis;
60
- let _classSuper = terminus_1.HealthIndicator;
61
- var ServiceHealthIndicator = _classThis = class extends _classSuper {
62
- constructor(clientProxy) {
63
- super();
64
- this.clientProxy = clientProxy;
65
- }
66
- isHealthy(eventName) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- try {
69
- if (!this.clientProxy) {
70
- return {
71
- [eventName]: {
72
- status: 'down',
73
- },
74
- };
75
- }
76
- const result = yield (0, rxjs_1.firstValueFrom)(this.clientProxy.send(eventName, { check: true }).pipe((0, operators_1.timeout)(10000)), {
77
- defaultValue: undefined,
78
- });
79
- return {
80
- [eventName]: result,
81
- };
82
- }
83
- catch (error) {
84
- throw new terminus_1.HealthCheckError(`${eventName} failed`, {
85
- [eventName]: error,
86
- });
87
- }
88
- });
89
- }
90
- };
91
- __setFunctionName(_classThis, "ServiceHealthIndicator");
92
- (() => {
93
- var _a;
94
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
95
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
96
- ServiceHealthIndicator = _classThis = _classDescriptor.value;
97
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
98
- __runInitializers(_classThis, _classExtraInitializers);
99
- })();
100
- return ServiceHealthIndicator = _classThis;
101
- })();
102
- exports.ServiceHealthIndicator = ServiceHealthIndicator;
@@ -1,44 +0,0 @@
1
- import { Inject, Injectable, Optional } from '@nestjs/common';
2
- import { ClientProxy } from '@nestjs/microservices';
3
- import type { HealthIndicatorResult } from '@nestjs/terminus';
4
- import { HealthCheckError, HealthIndicator } from '@nestjs/terminus';
5
- import { firstValueFrom } from 'rxjs';
6
- import { timeout } from 'rxjs/operators';
7
-
8
- @Injectable()
9
- export class ServiceHealthIndicator extends HealthIndicator {
10
- constructor(
11
- @Optional()
12
- @Inject('NATS_SERVICE')
13
- private readonly clientProxy?: ClientProxy,
14
- ) {
15
- super();
16
- }
17
-
18
- async isHealthy(eventName: string): Promise<HealthIndicatorResult> {
19
- try {
20
- if (!this.clientProxy) {
21
- return {
22
- [eventName]: {
23
- status: 'down',
24
- },
25
- };
26
- }
27
-
28
- const result = await firstValueFrom(
29
- this.clientProxy.send(eventName, { check: true }).pipe(timeout(10000)),
30
- {
31
- defaultValue: undefined,
32
- },
33
- );
34
-
35
- return {
36
- [eventName]: result,
37
- };
38
- } catch (error) {
39
- throw new HealthCheckError(`${eventName} failed`, {
40
- [eventName]: error,
41
- });
42
- }
43
- }
44
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * 将枚举值转换成数组
3
- * @param Enum 枚举
4
- */
5
- export declare function enumToArray<E>(Enum: any): E[];
6
- /**
7
- * 生成随机字符串
8
- * @param {number} length 生成长度
9
- * @param {string} charSet 指定字符集
10
- * @returns {string} 生成字符串
11
- */
12
- export declare const randomString: (length?: number, charSet?: string) => string;
13
- /**
14
- * 获取服务部署 IP 地址
15
- */
16
- export declare function getIPAdress(): string;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIPAdress = exports.randomString = exports.enumToArray = void 0;
4
- const os_1 = require("os");
5
- /**
6
- * 将枚举值转换成数组
7
- * @param Enum 枚举
8
- */
9
- function enumToArray(Enum) {
10
- return Object.keys(Enum)
11
- .filter((key) => typeof Enum[key] === 'number')
12
- .map((key) => Enum[key]);
13
- }
14
- exports.enumToArray = enumToArray;
15
- /**
16
- * 生成随机字符串
17
- * @param {number} length 生成长度
18
- * @param {string} charSet 指定字符集
19
- * @returns {string} 生成字符串
20
- */
21
- const randomString = (length = 8, charSet) => {
22
- charSet =
23
- charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
24
- let randomString = '';
25
- for (let i = 0; i < length; i++) {
26
- const randomPoz = Math.floor(Math.random() * charSet.length);
27
- randomString += charSet.substring(randomPoz, randomPoz + 1);
28
- }
29
- return randomString;
30
- };
31
- exports.randomString = randomString;
32
- /**
33
- * 获取服务部署 IP 地址
34
- */
35
- function getIPAdress() {
36
- const interfaces = (0, os_1.networkInterfaces)();
37
- for (const devName in interfaces) {
38
- const iface = interfaces[devName];
39
- for (let i = 0; i < iface.length; i++) {
40
- const alias = iface[i];
41
- if (alias.family === 'IPv4' &&
42
- alias.address !== '127.0.0.1' &&
43
- !alias.internal) {
44
- return alias.address;
45
- }
46
- }
47
- }
48
- }
49
- exports.getIPAdress = getIPAdress;
@@ -1,49 +0,0 @@
1
- import { networkInterfaces } from 'os';
2
-
3
- /**
4
- * 将枚举值转换成数组
5
- * @param Enum 枚举
6
- */
7
- export function enumToArray<E>(Enum: any): E[] {
8
- return Object.keys(Enum)
9
- .filter((key) => typeof Enum[key as any] === 'number')
10
- .map((key) => Enum[key]);
11
- }
12
-
13
- /**
14
- * 生成随机字符串
15
- * @param {number} length 生成长度
16
- * @param {string} charSet 指定字符集
17
- * @returns {string} 生成字符串
18
- */
19
- export const randomString = (length: number = 8, charSet?: string): string => {
20
- charSet =
21
- charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
22
- let randomString = '';
23
- for (let i = 0; i < length; i++) {
24
- const randomPoz = Math.floor(Math.random() * charSet.length);
25
- randomString += charSet.substring(randomPoz, randomPoz + 1);
26
- }
27
- return randomString;
28
- };
29
-
30
- /**
31
- * 获取服务部署 IP 地址
32
- */
33
- export function getIPAdress(): string {
34
- const interfaces = networkInterfaces();
35
-
36
- for (const devName in interfaces) {
37
- const iface = interfaces[devName];
38
- for (let i = 0; i < iface.length; i++) {
39
- const alias = iface[i];
40
- if (
41
- alias.family === 'IPv4' &&
42
- alias.address !== '127.0.0.1' &&
43
- !alias.internal
44
- ) {
45
- return alias.address;
46
- }
47
- }
48
- }
49
- }
@@ -1,10 +0,0 @@
1
- import { ColumnOptions } from 'typeorm/decorator/options/ColumnOptions';
2
- export declare function timestamp(value?: number): number;
3
- export declare function strToTimeStamp(str: string | Date): any;
4
- export declare function getTodayTimeStamp(): {
5
- startTime: any;
6
- endTime: any;
7
- };
8
- export declare function unixtimestampToDate(value: number): Date;
9
- export declare function formatDateTime(value: number | string, format?: string, holder?: string | null): string;
10
- export declare function timestampColumn(name: string): ColumnOptions;
@@ -1,81 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.timestampColumn = exports.formatDateTime = exports.unixtimestampToDate = exports.getTodayTimeStamp = exports.strToTimeStamp = exports.timestamp = void 0;
27
- const moment = __importStar(require("moment"));
28
- const _ = __importStar(require("lodash"));
29
- function timestamp(value) {
30
- if (!value) {
31
- value = moment.now();
32
- }
33
- return Math.round(value / 1000);
34
- }
35
- exports.timestamp = timestamp;
36
- function strToTimeStamp(str) {
37
- if (_.isEmpty(str)) {
38
- return 0;
39
- }
40
- return moment(str).unix();
41
- }
42
- exports.strToTimeStamp = strToTimeStamp;
43
- function getTodayTimeStamp() {
44
- const startTime = strToTimeStamp(moment().format('YYYY-MM-DD 00:00:00'));
45
- const endTime = strToTimeStamp(moment().format('YYYY-MM-DD 23:59:59'));
46
- return {
47
- startTime,
48
- endTime,
49
- };
50
- }
51
- exports.getTodayTimeStamp = getTodayTimeStamp;
52
- function unixtimestampToDate(value) {
53
- return moment(value * 1000).toDate();
54
- }
55
- exports.unixtimestampToDate = unixtimestampToDate;
56
- function formatDateTime(value, format = 'YYYY-MM-DD HH:mm:ss', holder = '') {
57
- if (value === 'now') {
58
- return moment().format(format);
59
- }
60
- if (typeof value === 'string') {
61
- return value;
62
- }
63
- if (value > 0) {
64
- return moment(value * 1000).format(format);
65
- }
66
- return holder;
67
- }
68
- exports.formatDateTime = formatDateTime;
69
- function timestampColumn(name) {
70
- return {
71
- type: 'int',
72
- name,
73
- nullable: false,
74
- default: 0,
75
- transformer: {
76
- to: (value) => value === 0 || /\d{10}/.test(value) ? value : strToTimeStamp(value),
77
- from: (value) => (!value ? value : formatDateTime),
78
- },
79
- };
80
- }
81
- exports.timestampColumn = timestampColumn;