@smartsoft001/nestjs 1.1.65 → 1.1.67

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartsoft001/nestjs",
3
- "version": "1.1.65",
3
+ "version": "1.1.67",
4
4
  "description": "Utils to nestjs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,21 +21,27 @@
21
21
  "@angular/common": "15.1.1",
22
22
  "@angular/core": "15.1.1",
23
23
  "@angular/platform-browser-dynamic": "15.1.1",
24
+ "@nestjs/axios": "^0.1.0",
24
25
  "@nestjs/common": "9.4.0",
25
26
  "@nestjs/passport": "^7.1.5",
27
+ "@nestjs/terminus": "^9.2.2",
28
+ "@nestjs/typeorm": "^9.0.1",
26
29
  "flatted": "^3.2.4",
27
30
  "guid-typescript": "1.0.9",
28
31
  "lodash": "^4.17.20",
29
32
  "md5": "2.3.0",
33
+ "mongodb": "^3.7.3",
30
34
  "passport-jwt": "4.0.0",
31
35
  "reflect-metadata": "0.1.13",
32
36
  "rxjs": "7.8.1"
33
37
  },
34
38
  "peerDependencies": {
35
- "@smartsoft001/domain-core": "1.1.65",
36
- "@smartsoft001/models": "1.1.65",
37
- "@smartsoft001/users": "1.1.65",
38
- "@smartsoft001/utils": "1.1.65",
39
+ "@smartsoft001/crud-shell-dtos": "1.1.67",
40
+ "@smartsoft001/domain-core": "1.1.67",
41
+ "@smartsoft001/models": "1.1.67",
42
+ "@smartsoft001/mongo": "1.1.67",
43
+ "@smartsoft001/users": "1.1.67",
44
+ "@smartsoft001/utils": "1.1.67",
39
45
  "util": "0.12.5",
40
46
  "tslib": "2.4.1"
41
47
  },
@@ -0,0 +1,10 @@
1
+ import { HealthCheckService, HttpHealthIndicator, MemoryHealthIndicator } from '@nestjs/terminus';
2
+ import { HealthDbService } from "../../services";
3
+ export declare class HealthController {
4
+ private health;
5
+ private http;
6
+ private memory;
7
+ private custom;
8
+ constructor(health: HealthCheckService, http: HttpHealthIndicator, memory: MemoryHealthIndicator, custom: HealthDbService);
9
+ check(): Promise<import("@nestjs/terminus").HealthCheckResult>;
10
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HealthController = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const terminus_1 = require("@nestjs/terminus");
7
+ const services_1 = require("../../services");
8
+ let HealthController = class HealthController {
9
+ constructor(health, http, memory, custom) {
10
+ this.health = health;
11
+ this.http = http;
12
+ this.memory = memory;
13
+ this.custom = custom;
14
+ }
15
+ check() {
16
+ return this.health.check([
17
+ () => this.http.pingCheck('google', 'https://google.com'),
18
+ () => this.memory.checkHeap('memory_heap', 150 * 1024 * 1024),
19
+ () => this.custom.isHealthy('database'),
20
+ ]);
21
+ }
22
+ };
23
+ tslib_1.__decorate([
24
+ (0, common_1.Get)(),
25
+ (0, terminus_1.HealthCheck)(),
26
+ tslib_1.__metadata("design:type", Function),
27
+ tslib_1.__metadata("design:paramtypes", []),
28
+ tslib_1.__metadata("design:returntype", void 0)
29
+ ], HealthController.prototype, "check", null);
30
+ HealthController = tslib_1.__decorate([
31
+ (0, common_1.Controller)('_app/health'),
32
+ tslib_1.__metadata("design:paramtypes", [terminus_1.HealthCheckService,
33
+ terminus_1.HttpHealthIndicator,
34
+ terminus_1.MemoryHealthIndicator,
35
+ services_1.HealthDbService])
36
+ ], HealthController);
37
+ exports.HealthController = HealthController;
38
+ //# sourceMappingURL=health.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.controller.js","sourceRoot":"","sources":["../../../../../../../../libs/shared/nestjs/src/lib/controllers/health/health.controller.ts"],"names":[],"mappings":";;;;AAAA,2CAAiD;AACjD,+CAK0B;AAC1B,6CAAiD;AAG1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,YACU,MAA0B,EAC1B,IAAyB,EACzB,MAA6B,EAC7B,MAAuB;QAHvB,WAAM,GAAN,MAAM,CAAoB;QAC1B,SAAI,GAAJ,IAAI,CAAqB;QACzB,WAAM,GAAN,MAAM,CAAuB;QAC7B,WAAM,GAAN,MAAM,CAAiB;IAC9B,CAAC;IAIJ,KAAK;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YACvB,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,oBAAoB,CAAC;YACzD,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;YAC7D,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;SACxC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AATC;IAAC,IAAA,YAAG,GAAE;IACL,IAAA,sBAAW,GAAE;;;;6CAOb;AAhBU,gBAAgB;IAD5B,IAAA,mBAAU,EAAC,aAAa,CAAC;6CAGN,6BAAkB;QACpB,8BAAmB;QACjB,gCAAqB;QACrB,0BAAe;GALtB,gBAAgB,CAiB5B;AAjBY,4CAAgB"}
@@ -0,0 +1,2 @@
1
+ import { HealthController } from "./health/health.controller";
2
+ export declare const CONTROLLERS: (typeof HealthController)[];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONTROLLERS = void 0;
4
+ const health_controller_1 = require("./health/health.controller");
5
+ exports.CONTROLLERS = [
6
+ health_controller_1.HealthController
7
+ ];
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/shared/nestjs/src/lib/controllers/index.ts"],"names":[],"mappings":";;;AAAA,kEAA8D;AAEjD,QAAA,WAAW,GAAG;IACzB,oCAAgB;CACjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { HealthIndicator, HealthIndicatorResult } from '@nestjs/terminus';
2
+ import { IItemRepository } from '@smartsoft001/domain-core';
3
+ export declare class HealthDbService extends HealthIndicator {
4
+ private repository;
5
+ constructor(repository: IItemRepository<any>);
6
+ isHealthy(key: string): Promise<HealthIndicatorResult>;
7
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HealthDbService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const terminus_1 = require("@nestjs/terminus");
6
+ const common_1 = require("@nestjs/common");
7
+ const domain_core_1 = require("@smartsoft001/domain-core");
8
+ let HealthDbService = class HealthDbService extends terminus_1.HealthIndicator {
9
+ constructor(repository) {
10
+ super();
11
+ this.repository = repository;
12
+ }
13
+ isHealthy(key) {
14
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
+ const dbKey = 'health';
16
+ try {
17
+ const item = yield this.repository.getById(dbKey);
18
+ const user = { username: '_' + key, permissions: [] };
19
+ const update = {
20
+ id: dbKey,
21
+ checkDate: new Date(),
22
+ };
23
+ if (!item) {
24
+ yield this.repository.create(update, user);
25
+ }
26
+ else {
27
+ yield this.repository.updatePartial(update, user);
28
+ }
29
+ return this.getStatus(key, true);
30
+ }
31
+ catch (e) {
32
+ return this.getStatus(key, false, { message: e.message });
33
+ }
34
+ });
35
+ }
36
+ };
37
+ HealthDbService = tslib_1.__decorate([
38
+ (0, common_1.Injectable)(),
39
+ tslib_1.__metadata("design:paramtypes", [domain_core_1.IItemRepository])
40
+ ], HealthDbService);
41
+ exports.HealthDbService = HealthDbService;
42
+ //# sourceMappingURL=health-db.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health-db.service.js","sourceRoot":"","sources":["../../../../../../../../libs/shared/nestjs/src/lib/services/health-db/health-db.service.ts"],"names":[],"mappings":";;;;AAAA,+CAA0E;AAC1E,2CAA4C;AAE5C,2DAA4D;AAGrD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,0BAAe;IAClD,YAAoB,UAAgC;QAClD,KAAK,EAAE,CAAC;QADU,eAAU,GAAV,UAAU,CAAsB;IAEpD,CAAC;IAEK,SAAS,CAAC,GAAW;;YACzB,MAAM,KAAK,GAAG,QAAQ,CAAC;YAEvB,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAClD,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;gBACtD,MAAM,MAAM,GAAG;oBACb,EAAE,EAAE,KAAK;oBACT,SAAS,EAAE,IAAI,IAAI,EAAE;iBACtB,CAAC;gBAEF,IAAI,CAAC,IAAI,EAAE;oBACT,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;iBAC5C;qBAAM;oBACL,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;iBACnD;gBAED,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;aAClC;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;aAC3D;QACH,CAAC;KAAA;CACF,CAAA;AA3BY,eAAe;IAD3B,IAAA,mBAAU,GAAE;6CAEqB,6BAAe;GADpC,eAAe,CA2B3B;AA3BY,0CAAe"}
@@ -0,0 +1,3 @@
1
+ import { HealthDbService } from "./health-db/health-db.service";
2
+ export * from "./health-db/health-db.service";
3
+ export declare const SERVICES: (typeof HealthDbService)[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SERVICES = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const health_db_service_1 = require("./health-db/health-db.service");
6
+ tslib_1.__exportStar(require("./health-db/health-db.service"), exports);
7
+ exports.SERVICES = [
8
+ health_db_service_1.HealthDbService
9
+ ];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/shared/nestjs/src/lib/services/index.ts"],"names":[],"mappings":";;;;AAAA,qEAAgE;AAEhE,wEAA8C;AAEjC,QAAA,QAAQ,GAAG;IACtB,mCAAe;CAChB,CAAC"}
@@ -1,5 +1,14 @@
1
- import { DynamicModule } from "@nestjs/common";
2
- import { SharedConfig } from "./shared.config";
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { SharedConfig } from './shared.config';
3
3
  export declare class SharedModule {
4
- static forRoot(config: SharedConfig): DynamicModule;
4
+ static forFeature(config: SharedConfig): DynamicModule;
5
+ static forRoot(config: SharedConfig & {
6
+ db: {
7
+ host: string;
8
+ port: number;
9
+ database: string;
10
+ username?: string;
11
+ password?: string;
12
+ };
13
+ }): DynamicModule;
5
14
  }
@@ -1,21 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SharedModule = void 0;
4
+ const terminus_1 = require("@nestjs/terminus");
5
+ const axios_1 = require("@nestjs/axios");
6
+ const mongo_1 = require("@smartsoft001/mongo");
4
7
  const jwt_strategy_1 = require("./auth/jwt.strategy");
5
8
  const shared_config_1 = require("./shared.config");
6
9
  const permission_service_1 = require("./auth/permission.service");
10
+ const controllers_1 = require("./controllers");
11
+ const services_1 = require("./services");
7
12
  class SharedModule {
8
- static forRoot(config) {
13
+ static forFeature(config) {
9
14
  return {
10
15
  module: SharedModule,
11
16
  providers: [
12
17
  { provide: shared_config_1.SharedConfig, useValue: config },
13
- jwt_strategy_1.JwtStrategy, permission_service_1.PermissionService
18
+ jwt_strategy_1.JwtStrategy,
19
+ permission_service_1.PermissionService,
14
20
  ],
15
21
  exports: [
16
22
  { provide: shared_config_1.SharedConfig, useValue: config },
17
- permission_service_1.PermissionService, jwt_strategy_1.JwtStrategy
18
- ]
23
+ permission_service_1.PermissionService,
24
+ jwt_strategy_1.JwtStrategy,
25
+ ],
26
+ };
27
+ }
28
+ static forRoot(config) {
29
+ return {
30
+ module: SharedModule,
31
+ controllers: [...controllers_1.CONTROLLERS],
32
+ imports: [
33
+ SharedModule.forFeature(config),
34
+ mongo_1.MongoModule.forRoot(Object.assign(Object.assign({}, config.db), { collection: '_app' })),
35
+ terminus_1.TerminusModule.forRoot({
36
+ errorLogStyle: 'json',
37
+ }),
38
+ axios_1.HttpModule,
39
+ ],
40
+ providers: [...services_1.SERVICES],
41
+ exports: [SharedModule.forFeature(config)],
19
42
  };
20
43
  }
21
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shared.module.js","sourceRoot":"","sources":["../../../../../../libs/shared/nestjs/src/lib/shared.module.ts"],"names":[],"mappings":";;;AAEA,sDAAgD;AAChD,mDAA6C;AAC7C,kEAA4D;AAG5D,MAAa,YAAY;IACrB,MAAM,CAAC,OAAO,CAAC,MAAoB;QAC/B,OAAO;YACH,MAAM,EAAE,YAAY;YACpB,SAAS,EAAE;gBACP,EAAE,OAAO,EAAE,4BAAY,EAAE,QAAQ,EAAE,MAAM,EAAE;gBAC3C,0BAAW,EAAE,sCAAiB;aACjC;YACD,OAAO,EAAE;gBACL,EAAE,OAAO,EAAE,4BAAY,EAAE,QAAQ,EAAE,MAAM,EAAE;gBAC3C,sCAAiB,EAAE,0BAAW;aACjC;SACJ,CAAA;IACL,CAAC;CACJ;AAdD,oCAcC"}
1
+ {"version":3,"file":"shared.module.js","sourceRoot":"","sources":["../../../../../../libs/shared/nestjs/src/lib/shared.module.ts"],"names":[],"mappings":";;;AACA,+CAAkD;AAClD,yCAA2C;AAE3C,+CAAkD;AAElD,sDAAkD;AAClD,mDAA+C;AAC/C,kEAA8D;AAC9D,+CAA4C;AAE5C,yCAAsC;AAEtC,MAAa,YAAY;IACvB,MAAM,CAAC,UAAU,CAAC,MAAoB;QACpC,OAAO;YACL,MAAM,EAAE,YAAY;YACpB,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,4BAAY,EAAE,QAAQ,EAAE,MAAM,EAAE;gBAC3C,0BAAW;gBACX,sCAAiB;aAClB;YACD,OAAO,EAAE;gBACP,EAAE,OAAO,EAAE,4BAAY,EAAE,QAAQ,EAAE,MAAM,EAAE;gBAC3C,sCAAiB;gBACjB,0BAAW;aACZ;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,OAAO,CACZ,MAQC;QAED,OAAO;YACL,MAAM,EAAE,YAAY;YACpB,WAAW,EAAE,CAAC,GAAG,yBAAW,CAAC;YAC7B,OAAO,EAAE;gBACP,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC;gBAC/B,mBAAW,CAAC,OAAO,iCACd,MAAM,CAAC,EAAE,KACZ,UAAU,EAAE,MAAM,IAClB;gBACF,yBAAc,CAAC,OAAO,CAAC;oBACrB,aAAa,EAAE,MAAM;iBACtB,CAAC;gBACF,kBAAU;aACX;YACD,SAAS,EAAE,CAAC,GAAG,mBAAQ,CAAC;YACxB,OAAO,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SAC3C,CAAC;IACJ,CAAC;CACF;AA9CD,oCA8CC"}