@tahminator/sapling 2.1.0-beta.0e8a97e8 → 2.1.0-beta.a2de2fb9
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 +20 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +20 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -409,7 +409,10 @@ let HealthRegistrar = class HealthRegistrar {
|
|
|
409
409
|
add(healthCheck) {
|
|
410
410
|
this._checks.push(healthCheck);
|
|
411
411
|
}
|
|
412
|
-
|
|
412
|
+
/**
|
|
413
|
+
* @internal used by Sapling library
|
|
414
|
+
*/
|
|
415
|
+
_seal() {
|
|
413
416
|
this._sealed = true;
|
|
414
417
|
}
|
|
415
418
|
async check() {
|
|
@@ -499,6 +502,22 @@ var Sapling = class Sapling {
|
|
|
499
502
|
static registerApp(app) {
|
|
500
503
|
app.use(express.default.text({ type: "application/json" }));
|
|
501
504
|
app.use(Sapling.json());
|
|
505
|
+
return new Proxy(app, { get(target, prop, receiver) {
|
|
506
|
+
if (prop === "listen") {
|
|
507
|
+
const originalListen = target[prop];
|
|
508
|
+
return function(...args) {
|
|
509
|
+
const server = originalListen.apply(target, args);
|
|
510
|
+
server.once("listening", () => {
|
|
511
|
+
Sapling.onStartup();
|
|
512
|
+
console.log("Sapling successfully initialized post-startup hooks on server start");
|
|
513
|
+
});
|
|
514
|
+
return server;
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
return Reflect.get(target, prop, receiver);
|
|
518
|
+
} });
|
|
519
|
+
}
|
|
520
|
+
static onStartup() {
|
|
502
521
|
_InjectableRegistry.get(HealthRegistrar)?.seal();
|
|
503
522
|
}
|
|
504
523
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -848,7 +848,8 @@ declare class Sapling {
|
|
|
848
848
|
* app.registerApp(app);
|
|
849
849
|
* ```
|
|
850
850
|
*/
|
|
851
|
-
static registerApp(app: e.Express):
|
|
851
|
+
static registerApp(app: e.Express): e.Express;
|
|
852
|
+
static onStartup(): void;
|
|
852
853
|
/**
|
|
853
854
|
* Serialize a value into a JSON string.
|
|
854
855
|
*
|
|
@@ -1099,7 +1100,10 @@ declare class HealthRegistrar {
|
|
|
1099
1100
|
private _sealed;
|
|
1100
1101
|
constructor();
|
|
1101
1102
|
add(healthCheck: HealthCheck): void;
|
|
1102
|
-
|
|
1103
|
+
/**
|
|
1104
|
+
* @internal used by Sapling library
|
|
1105
|
+
*/
|
|
1106
|
+
_seal(): void;
|
|
1103
1107
|
check(): Promise<boolean>;
|
|
1104
1108
|
}
|
|
1105
1109
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -848,7 +848,8 @@ declare class Sapling {
|
|
|
848
848
|
* app.registerApp(app);
|
|
849
849
|
* ```
|
|
850
850
|
*/
|
|
851
|
-
static registerApp(app: e.Express):
|
|
851
|
+
static registerApp(app: e.Express): e.Express;
|
|
852
|
+
static onStartup(): void;
|
|
852
853
|
/**
|
|
853
854
|
* Serialize a value into a JSON string.
|
|
854
855
|
*
|
|
@@ -1099,7 +1100,10 @@ declare class HealthRegistrar {
|
|
|
1099
1100
|
private _sealed;
|
|
1100
1101
|
constructor();
|
|
1101
1102
|
add(healthCheck: HealthCheck): void;
|
|
1102
|
-
|
|
1103
|
+
/**
|
|
1104
|
+
* @internal used by Sapling library
|
|
1105
|
+
*/
|
|
1106
|
+
_seal(): void;
|
|
1103
1107
|
check(): Promise<boolean>;
|
|
1104
1108
|
}
|
|
1105
1109
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -384,7 +384,10 @@ let HealthRegistrar = class HealthRegistrar {
|
|
|
384
384
|
add(healthCheck) {
|
|
385
385
|
this._checks.push(healthCheck);
|
|
386
386
|
}
|
|
387
|
-
|
|
387
|
+
/**
|
|
388
|
+
* @internal used by Sapling library
|
|
389
|
+
*/
|
|
390
|
+
_seal() {
|
|
388
391
|
this._sealed = true;
|
|
389
392
|
}
|
|
390
393
|
async check() {
|
|
@@ -474,6 +477,22 @@ var Sapling = class Sapling {
|
|
|
474
477
|
static registerApp(app) {
|
|
475
478
|
app.use(e.text({ type: "application/json" }));
|
|
476
479
|
app.use(Sapling.json());
|
|
480
|
+
return new Proxy(app, { get(target, prop, receiver) {
|
|
481
|
+
if (prop === "listen") {
|
|
482
|
+
const originalListen = target[prop];
|
|
483
|
+
return function(...args) {
|
|
484
|
+
const server = originalListen.apply(target, args);
|
|
485
|
+
server.once("listening", () => {
|
|
486
|
+
Sapling.onStartup();
|
|
487
|
+
console.log("Sapling successfully initialized post-startup hooks on server start");
|
|
488
|
+
});
|
|
489
|
+
return server;
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
return Reflect.get(target, prop, receiver);
|
|
493
|
+
} });
|
|
494
|
+
}
|
|
495
|
+
static onStartup() {
|
|
477
496
|
_InjectableRegistry.get(HealthRegistrar)?.seal();
|
|
478
497
|
}
|
|
479
498
|
/**
|