@tahminator/sapling 2.1.0-beta.0e8a97e8 → 2.1.0-beta.da115635
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 +23 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +23 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -499,6 +499,29 @@ var Sapling = class Sapling {
|
|
|
499
499
|
static registerApp(app) {
|
|
500
500
|
app.use(express.default.text({ type: "application/json" }));
|
|
501
501
|
app.use(Sapling.json());
|
|
502
|
+
return new Proxy(app, { get(target, prop, receiver) {
|
|
503
|
+
if (prop === "listen") {
|
|
504
|
+
const originalListen = target[prop];
|
|
505
|
+
return function(...args) {
|
|
506
|
+
const lastArg = args[args.length - 1];
|
|
507
|
+
let originalCallback;
|
|
508
|
+
if (typeof lastArg === "function") {
|
|
509
|
+
originalCallback = lastArg;
|
|
510
|
+
args.pop();
|
|
511
|
+
}
|
|
512
|
+
const server = originalListen.apply(target, args);
|
|
513
|
+
server.once("listening", function(...cbArgs) {
|
|
514
|
+
Sapling.onStartup();
|
|
515
|
+
console.log("Sapling successfully initialized post-startup hooks on server start");
|
|
516
|
+
if (originalCallback) originalCallback(...cbArgs);
|
|
517
|
+
});
|
|
518
|
+
return server;
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
return Reflect.get(target, prop, receiver);
|
|
522
|
+
} });
|
|
523
|
+
}
|
|
524
|
+
static onStartup() {
|
|
502
525
|
_InjectableRegistry.get(HealthRegistrar)?.seal();
|
|
503
526
|
}
|
|
504
527
|
/**
|
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
|
*
|
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
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -474,6 +474,29 @@ var Sapling = class Sapling {
|
|
|
474
474
|
static registerApp(app) {
|
|
475
475
|
app.use(e.text({ type: "application/json" }));
|
|
476
476
|
app.use(Sapling.json());
|
|
477
|
+
return new Proxy(app, { get(target, prop, receiver) {
|
|
478
|
+
if (prop === "listen") {
|
|
479
|
+
const originalListen = target[prop];
|
|
480
|
+
return function(...args) {
|
|
481
|
+
const lastArg = args[args.length - 1];
|
|
482
|
+
let originalCallback;
|
|
483
|
+
if (typeof lastArg === "function") {
|
|
484
|
+
originalCallback = lastArg;
|
|
485
|
+
args.pop();
|
|
486
|
+
}
|
|
487
|
+
const server = originalListen.apply(target, args);
|
|
488
|
+
server.once("listening", function(...cbArgs) {
|
|
489
|
+
Sapling.onStartup();
|
|
490
|
+
console.log("Sapling successfully initialized post-startup hooks on server start");
|
|
491
|
+
if (originalCallback) originalCallback(...cbArgs);
|
|
492
|
+
});
|
|
493
|
+
return server;
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
return Reflect.get(target, prop, receiver);
|
|
497
|
+
} });
|
|
498
|
+
}
|
|
499
|
+
static onStartup() {
|
|
477
500
|
_InjectableRegistry.get(HealthRegistrar)?.seal();
|
|
478
501
|
}
|
|
479
502
|
/**
|