@terreno/api-health 57.3.0 → 57.6.0

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
@@ -45,8 +45,8 @@ Returns `200` with `{healthy: true, ...}` when healthy, `503` when `healthy: fal
45
45
 
46
46
  ## Documentation
47
47
 
48
- Full API reference: [docs/reference/api-health.md](https://github.com/flourishhealth/terreno/blob/master/docs/reference/api-health.md)
48
+ Full API reference: [docs/reference/api-health.md](https://github.com/TerrenoLabs/terreno/blob/master/docs/reference/api-health.md)
49
49
 
50
50
  ## License and Contributing
51
51
 
52
- Licensed under the [MIT License](https://github.com/flourishhealth/terreno/blob/master/LICENSE). See [CONTRIBUTING.md](https://github.com/flourishhealth/terreno/blob/master/CONTRIBUTING.md) for contribution guidelines.
52
+ Licensed under the [MIT License](https://github.com/TerrenoLabs/terreno/blob/master/LICENSE). See [CONTRIBUTING.md](https://github.com/TerrenoLabs/terreno/blob/master/CONTRIBUTING.md) for contribution guidelines.
package/dist/healthApp.js CHANGED
@@ -1,40 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.HealthApp = void 0;
40
4
  /**
@@ -72,14 +36,15 @@ exports.HealthApp = void 0;
72
36
  * @see TerrenoPlugin for the plugin interface
73
37
  * @see TerrenoApp for the application builder
74
38
  */
75
- var HealthApp = /** @class */ (function () {
39
+ class HealthApp {
40
+ options;
76
41
  /**
77
42
  * Create a new HealthApp plugin.
78
43
  *
79
44
  * @param options - Health check configuration options
80
45
  */
81
- function HealthApp(options) {
82
- this.options = options !== null && options !== void 0 ? options : {};
46
+ constructor(options) {
47
+ this.options = options ?? {};
83
48
  }
84
49
  /**
85
50
  * Register the health check endpoint with the Express application.
@@ -91,39 +56,28 @@ var HealthApp = /** @class */ (function () {
91
56
  *
92
57
  * @param app - The Express application instance to register with
93
58
  */
94
- HealthApp.prototype.register = function (app) {
95
- var _this = this;
96
- var _a;
59
+ register(app) {
97
60
  if (this.options.enabled === false) {
98
61
  return;
99
62
  }
100
- var path = (_a = this.options.path) !== null && _a !== void 0 ? _a : "/health";
101
- var checkFn = this.options.check;
102
- app.get(path, function (_req, res) { return __awaiter(_this, void 0, void 0, function () {
103
- var result, status_1, error_1;
104
- return __generator(this, function (_a) {
105
- switch (_a.label) {
106
- case 0:
107
- if (!checkFn) return [3 /*break*/, 4];
108
- _a.label = 1;
109
- case 1:
110
- _a.trys.push([1, 3, , 4]);
111
- return [4 /*yield*/, checkFn()];
112
- case 2:
113
- result = _a.sent();
114
- status_1 = result.healthy ? 200 : 503;
115
- return [2 /*return*/, res.status(status_1).json(result)];
116
- case 3:
117
- error_1 = _a.sent();
118
- return [2 /*return*/, res.status(503).json({
119
- details: { error: error_1.message },
120
- healthy: false,
121
- })];
122
- case 4: return [2 /*return*/, res.json({ healthy: true })];
63
+ const path = this.options.path ?? "/health";
64
+ const checkFn = this.options.check;
65
+ app.get(path, async (_req, res) => {
66
+ if (checkFn) {
67
+ try {
68
+ const result = await checkFn();
69
+ const status = result.healthy ? 200 : 503;
70
+ return res.status(status).json(result);
71
+ }
72
+ catch (error) {
73
+ return res.status(503).json({
74
+ details: { error: error.message },
75
+ healthy: false,
76
+ });
123
77
  }
124
- });
125
- }); });
126
- };
127
- return HealthApp;
128
- }());
78
+ }
79
+ return res.json({ healthy: true });
80
+ });
81
+ }
82
+ }
129
83
  exports.HealthApp = HealthApp;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "author": "Josh Gachnang",
3
3
  "bugs": {
4
- "url": "https://github.com/FlourishHealth/terreno/issues"
4
+ "url": "https://github.com/TerrenoLabs/terreno/issues"
5
5
  },
6
6
  "dependencies": {
7
- "@terreno/api": "57.3.0",
7
+ "@terreno/api": "57.6.0",
8
8
  "express": "^5.2.1"
9
9
  },
10
10
  "description": "Health check plugin for @terreno/api — part of Terreno, the batteries-included TypeScript framework for universal apps.",
@@ -16,7 +16,7 @@
16
16
  "supertest": "^7.2.2",
17
17
  "typescript": "~6.0.3"
18
18
  },
19
- "homepage": "https://github.com/FlourishHealth/terreno#readme",
19
+ "homepage": "https://github.com/TerrenoLabs/terreno#readme",
20
20
  "keywords": [
21
21
  "health",
22
22
  "api",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "git+ssh://git@github.com/FlourishHealth/terreno.git"
34
+ "url": "git+ssh://git@github.com/TerrenoLabs/terreno.git"
35
35
  },
36
36
  "scripts": {
37
37
  "compile": "bun tsc",
@@ -45,5 +45,5 @@
45
45
  "test:coverage": "bun run ../scripts/check-coverage.ts"
46
46
  },
47
47
  "types": "dist/index.d.ts",
48
- "version": "57.3.0"
48
+ "version": "57.6.0"
49
49
  }
package/tsconfig.json CHANGED
@@ -1,33 +1,18 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "allowJs": true,
4
- "allowSyntheticDefaultImports": true,
5
- "baseUrl": "./",
6
3
  "declaration": true,
7
- "downlevelIteration": true,
8
- "esModuleInterop": true,
9
- "forceConsistentCasingInFileNames": true,
10
- "ignoreDeprecations": "6.0",
11
- "jsx": "react",
12
- "lib": ["es2017", "dom", "es2017.object"],
13
- "module": "commonjs",
14
- "moduleResolution": "node",
15
- "noEmit": false,
4
+ "isolatedModules": true,
5
+ "lib": ["es2023"],
6
+ "module": "nodenext",
16
7
  "noImplicitAny": false,
17
8
  "noImplicitReturns": true,
18
- "noImplicitThis": true,
19
- "noUnusedLocals": false,
20
- "noUnusedParameters": false,
21
9
  "outDir": "./dist",
22
10
  "rootDir": "./src",
23
- "preserveConstEnums": true,
24
- "removeComments": false,
25
11
  "skipLibCheck": true,
26
12
  "strict": true,
27
- "strictFunctionTypes": true,
28
- "strictNullChecks": true,
29
- "target": "es5"
13
+ "target": "es2023",
14
+ "types": ["node"]
30
15
  },
31
16
  "exclude": ["node_modules", "**/*.test.ts"],
32
- "include": ["src/**/*.ts*", "src/*.ts", "src/**/*.d.ts"]
17
+ "include": ["src"]
33
18
  }