rxnt-healthchecks-nestjs 1.0.1-alpha-1609

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 ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "rxnt-healthchecks-nestjs",
3
+ "version": "1.0.1-alpha-1609",
4
+ "description": "nestjs integration for rxnt-healthchecks",
5
+ "main": "src/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "node scripts/build.script.js",
10
+ "format": "prettier --write src/**/*",
11
+ "e2e": "mocha --timeout 15000",
12
+ "increment-version": "node ../scripts/increment-version.script.js",
13
+ "publish-package": "node ../scripts/publish.script.js"
14
+ },
15
+ "keywords": [
16
+ "healthcheck",
17
+ "health",
18
+ "nestjs"
19
+ ],
20
+ "author": "RXNT",
21
+ "license": "Private",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/RXNT/common.git",
25
+ "directory": "rxnt-healthchecks-package"
26
+ },
27
+ "dependencies": {
28
+ "@nestjs/common": "^10.4.1",
29
+ "@rxnt/healthchecks": "0.0.11-alpha-1607"
30
+ },
31
+ "devDependencies": {
32
+ "chai": "^4.3.7",
33
+ "chai-http": "^4.4.0",
34
+ "dotenv": "^16.3.1",
35
+ "mocha": "^10.2.0"
36
+ }
37
+ }
@@ -0,0 +1,16 @@
1
+ import { execSync } from "child_process";
2
+ import path from "path";
3
+
4
+ (async () => {
5
+ try {
6
+ execSync(
7
+ "npx tsc --declaration",
8
+ {
9
+ cwd: path.join(__dirname, "../"),
10
+ stdio: "inherit"
11
+ }
12
+ );
13
+ } catch {
14
+
15
+ }
16
+ })();
@@ -0,0 +1,9 @@
1
+ import { Module } from '@nestjs/common';
2
+ import { HealthCheckService } from './healthcheck.service'
3
+
4
+
5
+ @Module({
6
+ providers: [HealthCheckService],
7
+ exports: [HealthCheckService],
8
+ })
9
+ export class HealthCheckModule {}
@@ -0,0 +1,53 @@
1
+ import { Injectable, InternalServerErrorException } from '@nestjs/common';
2
+ import {
3
+ HealthCheckConfiguration,
4
+ HealthCheckHandler,
5
+ HealthReport,
6
+ HealthStatus,
7
+ HealthcheckRegistration
8
+ } from '@rxnt/healthchecks';
9
+
10
+ @Injectable()
11
+ export class HealthCheckService {
12
+
13
+ private readonly handler: HealthCheckHandler
14
+
15
+ constructor() {
16
+ this.handler = new HealthCheckHandler();
17
+ }
18
+
19
+ public Setup(configuration: HealthCheckConfiguration): void {
20
+ this.handler.setup(configuration)
21
+ }
22
+
23
+ public Start() {
24
+ this.handler.start();
25
+ }
26
+
27
+ public Stop() {
28
+ this.handler.stop();
29
+ }
30
+
31
+ public Reset() {
32
+ this.handler.reset();
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @param {string[]} tags
38
+ * @param {string} name
39
+ * @param {async ()} handler
40
+ */
41
+ public AddHealthCheck(tags: string[], name: string, check: HealthcheckRegistration) {
42
+ this.handler.addHealthCheck(tags, name, check);
43
+ }
44
+
45
+ public async ExecuteHealthCheckRequest(url): Promise<HealthReport> {
46
+ const result = await this.handler.executeHealthChecksForUrl(url);
47
+ if (result.status == HealthStatus.HEALTHY) {
48
+ return result
49
+ }
50
+ throw new InternalServerErrorException(result)
51
+ }
52
+
53
+ }
package/src/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import { HealthCheckModule } from './healthcheck.module'
2
+ import { HealthCheckService } from './healthcheck.service'
3
+
4
+
5
+ module.exports = {
6
+ HealthCheckModule,
7
+ HealthCheckService
8
+ }