@tahminator/sapling 2.1.1 → 2.1.3
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/dist/index.cjs +2 -2
- package/dist/index.d.cts +8 -19
- package/dist/index.d.mts +8 -19
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1227,11 +1227,11 @@ let DefaultHealthMiddleware = class DefaultHealthMiddleware {
|
|
|
1227
1227
|
}
|
|
1228
1228
|
async readiness(_request, _response, _next) {
|
|
1229
1229
|
const up = await this.healthRegistrar._readiness();
|
|
1230
|
-
return ResponseEntity.
|
|
1230
|
+
return ResponseEntity.status(up ? 200 : 503).body({ up });
|
|
1231
1231
|
}
|
|
1232
1232
|
async liveness(_request, _response, _next) {
|
|
1233
1233
|
const up = await this.healthRegistrar._liveness();
|
|
1234
|
-
return ResponseEntity.
|
|
1234
|
+
return ResponseEntity.status(up ? 200 : 503).body({ up });
|
|
1235
1235
|
}
|
|
1236
1236
|
};
|
|
1237
1237
|
__decorate([GET(_settings.health.ready.path)], DefaultHealthMiddleware.prototype, "readiness", null);
|
package/dist/index.d.cts
CHANGED
|
@@ -853,11 +853,6 @@ declare class Sapling {
|
|
|
853
853
|
* ```
|
|
854
854
|
*/
|
|
855
855
|
static registerApp(app: e.Express): e.Express;
|
|
856
|
-
/**
|
|
857
|
-
* @internal
|
|
858
|
-
* visible for testing
|
|
859
|
-
*/
|
|
860
|
-
static _onPostStartup(): void;
|
|
861
856
|
/**
|
|
862
857
|
* Serialize a value into a JSON string.
|
|
863
858
|
*
|
|
@@ -1130,26 +1125,20 @@ declare class HealthRegistrar {
|
|
|
1130
1125
|
* Health checks will be used to determine whether service can serve traffic or not (a.k.a `readiness`).
|
|
1131
1126
|
*/
|
|
1132
1127
|
add(healthCheck: HealthCheck): void;
|
|
1133
|
-
/**
|
|
1134
|
-
* @internal used by Sapling library, used to determine once all
|
|
1135
|
-
* checks have been registered and server is, at the very least, alive.
|
|
1136
|
-
*/
|
|
1137
|
-
_markLive(): void;
|
|
1138
|
-
/**
|
|
1139
|
-
* @internal
|
|
1140
|
-
*/
|
|
1141
|
-
_liveness(): Promise<boolean>;
|
|
1142
|
-
/**
|
|
1143
|
-
* @internal
|
|
1144
|
-
*/
|
|
1145
|
-
_readiness(): Promise<boolean>;
|
|
1146
1128
|
}
|
|
1147
1129
|
//#endregion
|
|
1148
1130
|
//#region src/middleware/default/health/index.d.ts
|
|
1149
1131
|
/**
|
|
1150
1132
|
* Enable the serving of `ready` and `live` endpoints.
|
|
1151
1133
|
*
|
|
1152
|
-
*
|
|
1134
|
+
* `live` and `ready` endpoint returns 200 with `{ up: true }`, else 503 with `{ up: false }`
|
|
1135
|
+
*
|
|
1136
|
+
* Customize endpoint paths with `Sapling.Extras.health`.
|
|
1137
|
+
* Register readiness checks via {@link HealthRegistrar}.
|
|
1138
|
+
*
|
|
1139
|
+
* explanation of `liveness` vs. `readiness`
|
|
1140
|
+
* @see https://kubernetes.io/docs/concepts/workloads/pods/probes/#liveness-probe
|
|
1141
|
+
* @see https://kubernetes.io/docs/concepts/workloads/pods/probes/#readiness-probe
|
|
1153
1142
|
*/
|
|
1154
1143
|
declare class DefaultHealthMiddleware {
|
|
1155
1144
|
private readonly healthRegistrar;
|
package/dist/index.d.mts
CHANGED
|
@@ -853,11 +853,6 @@ declare class Sapling {
|
|
|
853
853
|
* ```
|
|
854
854
|
*/
|
|
855
855
|
static registerApp(app: e.Express): e.Express;
|
|
856
|
-
/**
|
|
857
|
-
* @internal
|
|
858
|
-
* visible for testing
|
|
859
|
-
*/
|
|
860
|
-
static _onPostStartup(): void;
|
|
861
856
|
/**
|
|
862
857
|
* Serialize a value into a JSON string.
|
|
863
858
|
*
|
|
@@ -1130,26 +1125,20 @@ declare class HealthRegistrar {
|
|
|
1130
1125
|
* Health checks will be used to determine whether service can serve traffic or not (a.k.a `readiness`).
|
|
1131
1126
|
*/
|
|
1132
1127
|
add(healthCheck: HealthCheck): void;
|
|
1133
|
-
/**
|
|
1134
|
-
* @internal used by Sapling library, used to determine once all
|
|
1135
|
-
* checks have been registered and server is, at the very least, alive.
|
|
1136
|
-
*/
|
|
1137
|
-
_markLive(): void;
|
|
1138
|
-
/**
|
|
1139
|
-
* @internal
|
|
1140
|
-
*/
|
|
1141
|
-
_liveness(): Promise<boolean>;
|
|
1142
|
-
/**
|
|
1143
|
-
* @internal
|
|
1144
|
-
*/
|
|
1145
|
-
_readiness(): Promise<boolean>;
|
|
1146
1128
|
}
|
|
1147
1129
|
//#endregion
|
|
1148
1130
|
//#region src/middleware/default/health/index.d.ts
|
|
1149
1131
|
/**
|
|
1150
1132
|
* Enable the serving of `ready` and `live` endpoints.
|
|
1151
1133
|
*
|
|
1152
|
-
*
|
|
1134
|
+
* `live` and `ready` endpoint returns 200 with `{ up: true }`, else 503 with `{ up: false }`
|
|
1135
|
+
*
|
|
1136
|
+
* Customize endpoint paths with `Sapling.Extras.health`.
|
|
1137
|
+
* Register readiness checks via {@link HealthRegistrar}.
|
|
1138
|
+
*
|
|
1139
|
+
* explanation of `liveness` vs. `readiness`
|
|
1140
|
+
* @see https://kubernetes.io/docs/concepts/workloads/pods/probes/#liveness-probe
|
|
1141
|
+
* @see https://kubernetes.io/docs/concepts/workloads/pods/probes/#readiness-probe
|
|
1153
1142
|
*/
|
|
1154
1143
|
declare class DefaultHealthMiddleware {
|
|
1155
1144
|
private readonly healthRegistrar;
|
package/dist/index.mjs
CHANGED
|
@@ -1202,11 +1202,11 @@ let DefaultHealthMiddleware = class DefaultHealthMiddleware {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
async readiness(_request, _response, _next) {
|
|
1204
1204
|
const up = await this.healthRegistrar._readiness();
|
|
1205
|
-
return ResponseEntity.
|
|
1205
|
+
return ResponseEntity.status(up ? 200 : 503).body({ up });
|
|
1206
1206
|
}
|
|
1207
1207
|
async liveness(_request, _response, _next) {
|
|
1208
1208
|
const up = await this.healthRegistrar._liveness();
|
|
1209
|
-
return ResponseEntity.
|
|
1209
|
+
return ResponseEntity.status(up ? 200 : 503).body({ up });
|
|
1210
1210
|
}
|
|
1211
1211
|
};
|
|
1212
1212
|
__decorate([GET(_settings.health.ready.path)], DefaultHealthMiddleware.prototype, "readiness", null);
|