nestjs-api-forge 1.0.5 → 1.0.7

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/README.md CHANGED
@@ -473,23 +473,37 @@ rxjs ^7
473
473
 
474
474
  ## 📋 Changelog
475
475
 
476
- ### v1.1.0
476
+ ### v1.0.7 — Current
477
+
478
+ - **10 new HTTP exception classes** — `NotAcceptableException` (406), `RequestTimeoutException` (408), `GoneException` (410), `PayloadTooLargeException` (413), `UnsupportedMediaTypeException` (415), `LockedException` (423), `FailedDependencyException` (424), `PreconditionRequiredException` (428), `NotImplementedException` (501), `BadGatewayException` (502)
479
+ - **`ForgeHealthModule`** — configurable `/health` endpoint with custom checks, uptime, memory stats, and Forge-formatted responses; throws 503 automatically when any check fails
480
+ - **Updated error-code map** — added `LOCKED`, `FAILED_DEPENDENCY`, `PRECONDITION_REQUIRED` mappings
481
+
482
+ > Full history: [CHANGELOG.md](CHANGELOG.md)
483
+
484
+ ### v1.0.6
485
+ - **Changelog updated** — all versions documented with accurate entries aligned to npm release history
486
+
487
+ ### v1.0.5
488
+ - **Open source documentation** — full README rewrite with badges, "What it does" table, response shape examples, and complete API reference
489
+ - **Community health files** — `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `CONTRIBUTORS.md`, `REPOSITORY_RULES.md`
490
+ - **GitHub templates** — bug report and feature request issue templates, `FUNDING.yml`, `CODEOWNERS`
491
+ - **ESLint setup** — ESLint v10 flat config (`eslint.config.mjs`) with `@typescript-eslint` integration; `npm run lint` now works out of the box
492
+
493
+ ### v1.0.4
477
494
  - `ForgeValidationPipe` — structured validation errors with nested field support (dot-notation)
478
495
  - `@ForgeMeta(extra)` — merge custom fields into response `meta` per route or controller
479
496
  - `@ForgeDeprecated(notice?)` — deprecation flag in `meta` + `Deprecation: true` response header
497
+ - `@ForgeMessage`, `@ForgeRawResponse`, `@ApiForge` decorators
480
498
  - `ApiResponseDto.accepted()` — 202 Accepted helper
481
499
  - Correlation ID passthrough (`correlationIdHeader` option)
482
500
  - Response time measurement (`includeResponseTime` option)
483
501
  - `forRootAsync` fix — options factory now runs once instead of twice
484
502
  - 3 new exceptions: `MethodNotAllowedException`, `PaymentRequiredException`, `GatewayTimeoutException`
485
-
486
- ### v1.0.4
487
- - Decorators: `@ForgeMessage`, `@ForgeRawResponse`, `@ForgeMeta`, `@ForgeDeprecated`, `@ApiForge`
488
- - `ForgeValidationPipe` with structured field-level errors
489
503
  - Response metadata support (`includePath`, `includeTimestamp`, `includeRequestId`, `includeResponseTime`)
490
504
 
491
505
  ### v1.0.3
492
- - Bump version, update repository URL
506
+ - Update repository URL format in `package.json`
493
507
 
494
508
  ### v1.0.0
495
509
  - Initial release — `ApiForgeModule.forRoot()`, `ForgeExceptionFilter`, `ForgeResponseInterceptor`, `ApiResponseDto`, and 10 typed exceptions
@@ -41,3 +41,33 @@ export declare class PaymentRequiredException extends ApiException {
41
41
  export declare class GatewayTimeoutException extends ApiException {
42
42
  constructor(message?: string);
43
43
  }
44
+ export declare class NotAcceptableException extends ApiException {
45
+ constructor(message?: string);
46
+ }
47
+ export declare class RequestTimeoutException extends ApiException {
48
+ constructor(message?: string);
49
+ }
50
+ export declare class GoneException extends ApiException {
51
+ constructor(message?: string);
52
+ }
53
+ export declare class PayloadTooLargeException extends ApiException {
54
+ constructor(message?: string);
55
+ }
56
+ export declare class UnsupportedMediaTypeException extends ApiException {
57
+ constructor(message?: string);
58
+ }
59
+ export declare class LockedException extends ApiException {
60
+ constructor(message?: string);
61
+ }
62
+ export declare class FailedDependencyException extends ApiException {
63
+ constructor(message?: string);
64
+ }
65
+ export declare class PreconditionRequiredException extends ApiException {
66
+ constructor(message?: string);
67
+ }
68
+ export declare class NotImplementedException extends ApiException {
69
+ constructor(message?: string);
70
+ }
71
+ export declare class BadGatewayException extends ApiException {
72
+ constructor(message?: string);
73
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GatewayTimeoutException = exports.PaymentRequiredException = exports.MethodNotAllowedException = exports.ServiceUnavailableException = exports.InternalServerException = exports.TooManyRequestsException = exports.UnprocessableEntityException = exports.ConflictException = exports.NotFoundException = exports.ForbiddenException = exports.UnauthorizedException = exports.BadRequestException = exports.ApiException = void 0;
3
+ exports.BadGatewayException = exports.NotImplementedException = exports.PreconditionRequiredException = exports.FailedDependencyException = exports.LockedException = exports.UnsupportedMediaTypeException = exports.PayloadTooLargeException = exports.GoneException = exports.RequestTimeoutException = exports.NotAcceptableException = exports.GatewayTimeoutException = exports.PaymentRequiredException = exports.MethodNotAllowedException = exports.ServiceUnavailableException = exports.InternalServerException = exports.TooManyRequestsException = exports.UnprocessableEntityException = exports.ConflictException = exports.NotFoundException = exports.ForbiddenException = exports.UnauthorizedException = exports.BadRequestException = exports.ApiException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  class ApiException extends common_1.HttpException {
6
6
  constructor(message, statusCode, code, details) {
@@ -82,4 +82,64 @@ class GatewayTimeoutException extends ApiException {
82
82
  }
83
83
  }
84
84
  exports.GatewayTimeoutException = GatewayTimeoutException;
85
+ class NotAcceptableException extends ApiException {
86
+ constructor(message = 'Not acceptable') {
87
+ super(message, common_1.HttpStatus.NOT_ACCEPTABLE, 'NOT_ACCEPTABLE');
88
+ }
89
+ }
90
+ exports.NotAcceptableException = NotAcceptableException;
91
+ class RequestTimeoutException extends ApiException {
92
+ constructor(message = 'Request timeout') {
93
+ super(message, common_1.HttpStatus.REQUEST_TIMEOUT, 'REQUEST_TIMEOUT');
94
+ }
95
+ }
96
+ exports.RequestTimeoutException = RequestTimeoutException;
97
+ class GoneException extends ApiException {
98
+ constructor(message = 'Resource no longer available') {
99
+ super(message, common_1.HttpStatus.GONE, 'GONE');
100
+ }
101
+ }
102
+ exports.GoneException = GoneException;
103
+ class PayloadTooLargeException extends ApiException {
104
+ constructor(message = 'Payload too large') {
105
+ super(message, common_1.HttpStatus.PAYLOAD_TOO_LARGE, 'PAYLOAD_TOO_LARGE');
106
+ }
107
+ }
108
+ exports.PayloadTooLargeException = PayloadTooLargeException;
109
+ class UnsupportedMediaTypeException extends ApiException {
110
+ constructor(message = 'Unsupported media type') {
111
+ super(message, common_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE, 'UNSUPPORTED_MEDIA_TYPE');
112
+ }
113
+ }
114
+ exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException;
115
+ class LockedException extends ApiException {
116
+ constructor(message = 'Resource is locked') {
117
+ super(message, common_1.HttpStatus.LOCKED, 'LOCKED');
118
+ }
119
+ }
120
+ exports.LockedException = LockedException;
121
+ class FailedDependencyException extends ApiException {
122
+ constructor(message = 'Failed dependency') {
123
+ super(message, common_1.HttpStatus.FAILED_DEPENDENCY, 'FAILED_DEPENDENCY');
124
+ }
125
+ }
126
+ exports.FailedDependencyException = FailedDependencyException;
127
+ class PreconditionRequiredException extends ApiException {
128
+ constructor(message = 'Precondition required') {
129
+ super(message, common_1.HttpStatus.PRECONDITION_REQUIRED, 'PRECONDITION_REQUIRED');
130
+ }
131
+ }
132
+ exports.PreconditionRequiredException = PreconditionRequiredException;
133
+ class NotImplementedException extends ApiException {
134
+ constructor(message = 'Not implemented') {
135
+ super(message, common_1.HttpStatus.NOT_IMPLEMENTED, 'NOT_IMPLEMENTED');
136
+ }
137
+ }
138
+ exports.NotImplementedException = NotImplementedException;
139
+ class BadGatewayException extends ApiException {
140
+ constructor(message = 'Bad gateway') {
141
+ super(message, common_1.HttpStatus.BAD_GATEWAY, 'BAD_GATEWAY');
142
+ }
143
+ }
144
+ exports.BadGatewayException = BadGatewayException;
85
145
  //# sourceMappingURL=api.exception.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.exception.js","sourceRoot":"","sources":["../../src/exceptions/api.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAG3D,MAAa,YAAa,SAAQ,sBAAa;IAC7C,YACE,OAAe,EACf,UAAsB,EACN,IAAY,EACZ,OAA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AAED,MAAa,uBAAwB,SAAQ,YAAY;IACvD,YAAY,OAAO,GAAG,iBAAiB;QACrC,KAAK,CAAC,OAAO,EAAE,mBAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;IAChE,CAAC;CACF;AAJD,0DAIC;AAED,MAAa,mBAAoB,SAAQ,YAAY;IACnD,YAAY,OAAO,GAAG,aAAa;QACjC,KAAK,CAAC,OAAO,EAAE,mBAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACF;AAJD,kDAIC"}
@@ -0,0 +1,6 @@
1
+ import { ForgeHealthService } from './forge-health.service';
2
+ export declare class ForgeHealthController {
3
+ protected readonly healthService: ForgeHealthService;
4
+ constructor(healthService: ForgeHealthService);
5
+ health(): Promise<import("..").ApiSuccessResponse<import("./forge-health.interfaces").ForgeHealthData>>;
6
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ForgeHealthController = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const dto_1 = require("../dto");
15
+ const decorators_1 = require("../decorators");
16
+ const exceptions_1 = require("../exceptions");
17
+ const forge_health_service_1 = require("./forge-health.service");
18
+ let ForgeHealthController = class ForgeHealthController {
19
+ constructor(healthService) {
20
+ this.healthService = healthService;
21
+ }
22
+ async health() {
23
+ const { data, ok } = await this.healthService.check();
24
+ if (!ok) {
25
+ throw new exceptions_1.ServiceUnavailableException('Service health checks failed');
26
+ }
27
+ return dto_1.ApiResponseDto.success(data, 'Service is healthy');
28
+ }
29
+ };
30
+ exports.ForgeHealthController = ForgeHealthController;
31
+ __decorate([
32
+ (0, common_1.Get)(),
33
+ (0, decorators_1.ForgeRawResponse)(),
34
+ __metadata("design:type", Function),
35
+ __metadata("design:paramtypes", []),
36
+ __metadata("design:returntype", Promise)
37
+ ], ForgeHealthController.prototype, "health", null);
38
+ exports.ForgeHealthController = ForgeHealthController = __decorate([
39
+ (0, common_1.Controller)(),
40
+ __metadata("design:paramtypes", [forge_health_service_1.ForgeHealthService])
41
+ ], ForgeHealthController);
42
+ //# sourceMappingURL=forge-health.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge-health.controller.js","sourceRoot":"","sources":["../../src/health/forge-health.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,gCAAwC;AACxC,8CAAiD;AACjD,8CAA4D;AAC5D,iEAA4D;AAGrD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAA+B,aAAiC;QAAjC,kBAAa,GAAb,aAAa,CAAoB;IAAG,CAAC;IAI9D,AAAN,KAAK,CAAC,MAAM;QACV,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAEtD,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,wCAA2B,CAAC,8BAA8B,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,oBAAc,CAAC,OAAO,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IAC5D,CAAC;CACF,CAAA;AAdY,sDAAqB;AAK1B;IAFL,IAAA,YAAG,GAAE;IACL,IAAA,6BAAgB,GAAE;;;;mDASlB;gCAbU,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAEmC,yCAAkB;GADrD,qBAAqB,CAcjC"}
@@ -0,0 +1,29 @@
1
+ export interface ForgeHealthCheckResult {
2
+ status: 'ok' | 'error';
3
+ message?: string;
4
+ details?: unknown;
5
+ }
6
+ export interface ForgeHealthCheck {
7
+ name: string;
8
+ check: () => Promise<ForgeHealthCheckResult> | ForgeHealthCheckResult;
9
+ }
10
+ export interface ForgeHealthOptions {
11
+ path?: string;
12
+ includeUptime?: boolean;
13
+ includeMemory?: boolean;
14
+ version?: string;
15
+ checks?: ForgeHealthCheck[];
16
+ }
17
+ export interface ForgeHealthMemory {
18
+ rss: number;
19
+ heapUsed: number;
20
+ heapTotal: number;
21
+ external: number;
22
+ }
23
+ export interface ForgeHealthData {
24
+ status: 'ok' | 'degraded';
25
+ uptime?: number;
26
+ version?: string;
27
+ memory?: ForgeHealthMemory;
28
+ checks?: Record<string, ForgeHealthCheckResult>;
29
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=forge-health.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge-health.interfaces.js","sourceRoot":"","sources":["../../src/health/forge-health.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { ForgeHealthOptions } from './forge-health.interfaces';
3
+ export declare class ForgeHealthModule {
4
+ static register(options?: ForgeHealthOptions): DynamicModule;
5
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var ForgeHealthModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ForgeHealthModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const forge_health_controller_1 = require("./forge-health.controller");
13
+ const forge_health_service_1 = require("./forge-health.service");
14
+ let ForgeHealthModule = ForgeHealthModule_1 = class ForgeHealthModule {
15
+ static register(options = {}) {
16
+ const path = options.path ?? 'health';
17
+ let DynamicHealthController = class DynamicHealthController extends forge_health_controller_1.ForgeHealthController {
18
+ };
19
+ DynamicHealthController = __decorate([
20
+ (0, common_1.Controller)(path)
21
+ ], DynamicHealthController);
22
+ return {
23
+ module: ForgeHealthModule_1,
24
+ providers: [
25
+ { provide: forge_health_service_1.FORGE_HEALTH_OPTIONS, useValue: options },
26
+ forge_health_service_1.ForgeHealthService,
27
+ ],
28
+ controllers: [DynamicHealthController],
29
+ };
30
+ }
31
+ };
32
+ exports.ForgeHealthModule = ForgeHealthModule;
33
+ exports.ForgeHealthModule = ForgeHealthModule = ForgeHealthModule_1 = __decorate([
34
+ (0, common_1.Module)({})
35
+ ], ForgeHealthModule);
36
+ //# sourceMappingURL=forge-health.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge-health.module.js","sourceRoot":"","sources":["../../src/health/forge-health.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAmE;AACnE,uEAAkE;AAElE,iEAAkF;AAG3E,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IACrB,AAAP,MAAM,CAAC,QAAQ,CAAC,UAA8B,EAAE;QAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC;QAGtC,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,+CAAqB;SAAG,CAAA;QAAxD,uBAAuB;YAD5B,IAAA,mBAAU,EAAC,IAAI,CAAC;WACX,uBAAuB,CAAiC;QAE9D,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,2CAAoB,EAAE,QAAQ,EAAE,OAAO,EAAE;gBACpD,yCAAkB;aACnB;YACD,WAAW,EAAE,CAAC,uBAAuB,CAAC;SACvC,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CAgB7B"}
@@ -0,0 +1,10 @@
1
+ import { ForgeHealthData, ForgeHealthOptions } from './forge-health.interfaces';
2
+ export declare const FORGE_HEALTH_OPTIONS = "FORGE_HEALTH_OPTIONS";
3
+ export declare class ForgeHealthService {
4
+ private readonly options;
5
+ constructor(options: ForgeHealthOptions);
6
+ check(): Promise<{
7
+ data: ForgeHealthData;
8
+ ok: boolean;
9
+ }>;
10
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ForgeHealthService = exports.FORGE_HEALTH_OPTIONS = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ exports.FORGE_HEALTH_OPTIONS = 'FORGE_HEALTH_OPTIONS';
18
+ let ForgeHealthService = class ForgeHealthService {
19
+ constructor(options) {
20
+ this.options = options;
21
+ }
22
+ async check() {
23
+ const data = { status: 'ok' };
24
+ if (this.options.includeUptime !== false) {
25
+ data.uptime = Math.round(process.uptime() * 1000) / 1000;
26
+ }
27
+ if (this.options.version) {
28
+ data.version = this.options.version;
29
+ }
30
+ if (this.options.includeMemory) {
31
+ const mem = process.memoryUsage();
32
+ data.memory = {
33
+ rss: mem.rss,
34
+ heapUsed: mem.heapUsed,
35
+ heapTotal: mem.heapTotal,
36
+ external: mem.external,
37
+ };
38
+ }
39
+ let ok = true;
40
+ if (this.options.checks?.length) {
41
+ data.checks = {};
42
+ for (const check of this.options.checks) {
43
+ try {
44
+ const result = await check.check();
45
+ data.checks[check.name] = result;
46
+ if (result.status === 'error')
47
+ ok = false;
48
+ }
49
+ catch (err) {
50
+ const message = err instanceof Error ? err.message : 'Check failed';
51
+ data.checks[check.name] = { status: 'error', message };
52
+ ok = false;
53
+ }
54
+ }
55
+ if (!ok)
56
+ data.status = 'degraded';
57
+ }
58
+ return { data, ok };
59
+ }
60
+ };
61
+ exports.ForgeHealthService = ForgeHealthService;
62
+ exports.ForgeHealthService = ForgeHealthService = __decorate([
63
+ (0, common_1.Injectable)(),
64
+ __param(0, (0, common_1.Inject)(exports.FORGE_HEALTH_OPTIONS)),
65
+ __metadata("design:paramtypes", [Object])
66
+ ], ForgeHealthService);
67
+ //# sourceMappingURL=forge-health.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge-health.service.js","sourceRoot":"","sources":["../../src/health/forge-health.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAMvC,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAGpD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YACiD,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IACzE,CAAC;IAEJ,KAAK,CAAC,KA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KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC;oBACpE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;oBACvD,EAAE,GAAG,KAAK,CAAC;gBACb,CAAC;YACH,CAAC;YACD,IAAI,CAAC,EAAE;gBAAE,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;QACpC,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IACtB,CAAC;CACF,CAAA;AA9CY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,4BAAoB,CAAC,CAAA;;GAFpB,kBAAkB,CA8C9B"}
@@ -0,0 +1,3 @@
1
+ export * from './forge-health.interfaces';
2
+ export * from './forge-health.module';
3
+ export * from './forge-health.service';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./forge-health.interfaces"), exports);
18
+ __exportStar(require("./forge-health.module"), exports);
19
+ __exportStar(require("./forge-health.service"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/health/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,wDAAsC;AACtC,yDAAuC"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './decorators';
3
3
  export * from './dto';
4
4
  export * from './exceptions';
5
5
  export * from './filters';
6
+ export * from './health';
6
7
  export * from './interceptors';
7
8
  export * from './interfaces';
8
9
  export * from './pipes';
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ __exportStar(require("./decorators"), exports);
19
19
  __exportStar(require("./dto"), exports);
20
20
  __exportStar(require("./exceptions"), exports);
21
21
  __exportStar(require("./filters"), exports);
22
+ __exportStar(require("./health"), exports);
22
23
  __exportStar(require("./interceptors"), exports);
23
24
  __exportStar(require("./interfaces"), exports);
24
25
  __exportStar(require("./pipes"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,+CAA6B;AAC7B,wCAAsB;AACtB,+CAA6B;AAC7B,4CAA0B;AAC1B,iDAA+B;AAC/B,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,+CAA6B;AAC7B,wCAAsB;AACtB,+CAA6B;AAC7B,4CAA0B;AAC1B,2CAAyB;AACzB,iDAA+B;AAC/B,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB"}