@tahminator/sapling 2.1.0-beta.a2de2fb9 → 2.1.0-beta.bcb66b15

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 CHANGED
@@ -401,22 +401,23 @@ function __decorate(decorators, target, key, desc) {
401
401
  //#region src/middleware/health/registrar.ts
402
402
  let HealthRegistrar = class HealthRegistrar {
403
403
  _checks;
404
- _sealed;
404
+ _ready;
405
405
  constructor() {
406
406
  this._checks = [];
407
- this._sealed = false;
407
+ this._ready = false;
408
408
  }
409
409
  add(healthCheck) {
410
410
  this._checks.push(healthCheck);
411
411
  }
412
412
  /**
413
- * @internal used by Sapling library
413
+ * @internal used by Sapling library, used to determine once all
414
+ * checks have been registered and server is, at the very least, alive.
414
415
  */
415
- _seal() {
416
- this._sealed = true;
416
+ _markReady() {
417
+ this._ready = true;
417
418
  }
418
419
  async check() {
419
- if (!this._sealed) return false;
420
+ if (!this._ready) return false;
420
421
  return (await Promise.all(this._checks.map((c) => c()))).every((c) => c === true);
421
422
  }
422
423
  };
@@ -494,9 +495,8 @@ var Sapling = class Sapling {
494
495
  * import { Sapling } from "@tahminator/sapling";
495
496
  * import express from "express";
496
497
  *
497
- * const app = express();
498
- *
499
- * app.registerApp(app);
498
+ * // returns the exact same `express.App` type back to you!
499
+ * const app = Sapling.registerApp(express());
500
500
  * ```
501
501
  */
502
502
  static registerApp(app) {
@@ -508,7 +508,7 @@ var Sapling = class Sapling {
508
508
  return function(...args) {
509
509
  const server = originalListen.apply(target, args);
510
510
  server.once("listening", () => {
511
- Sapling.onStartup();
511
+ Sapling.onPostStartup();
512
512
  console.log("Sapling successfully initialized post-startup hooks on server start");
513
513
  });
514
514
  return server;
@@ -517,8 +517,8 @@ var Sapling = class Sapling {
517
517
  return Reflect.get(target, prop, receiver);
518
518
  } });
519
519
  }
520
- static onStartup() {
521
- _InjectableRegistry.get(HealthRegistrar)?.seal();
520
+ static onPostStartup() {
521
+ _InjectableRegistry.get(HealthRegistrar)?._markReady();
522
522
  }
523
523
  /**
524
524
  * Serialize a value into a JSON string.
package/dist/index.d.cts CHANGED
@@ -843,13 +843,12 @@ declare class Sapling {
843
843
  * import { Sapling } from "@tahminator/sapling";
844
844
  * import express from "express";
845
845
  *
846
- * const app = express();
847
- *
848
- * app.registerApp(app);
846
+ * // returns the exact same `express.App` type back to you!
847
+ * const app = Sapling.registerApp(express());
849
848
  * ```
850
849
  */
851
850
  static registerApp(app: e.Express): e.Express;
852
- static onStartup(): void;
851
+ static onPostStartup(): void;
853
852
  /**
854
853
  * Serialize a value into a JSON string.
855
854
  *
@@ -1097,13 +1096,14 @@ declare const DefaultSwaggerMiddleware: {
1097
1096
  type HealthCheck = () => boolean | Promise<boolean>;
1098
1097
  declare class HealthRegistrar {
1099
1098
  private _checks;
1100
- private _sealed;
1099
+ private _ready;
1101
1100
  constructor();
1102
1101
  add(healthCheck: HealthCheck): void;
1103
1102
  /**
1104
- * @internal used by Sapling library
1103
+ * @internal used by Sapling library, used to determine once all
1104
+ * checks have been registered and server is, at the very least, alive.
1105
1105
  */
1106
- _seal(): void;
1106
+ _markReady(): void;
1107
1107
  check(): Promise<boolean>;
1108
1108
  }
1109
1109
  //#endregion
package/dist/index.d.mts CHANGED
@@ -843,13 +843,12 @@ declare class Sapling {
843
843
  * import { Sapling } from "@tahminator/sapling";
844
844
  * import express from "express";
845
845
  *
846
- * const app = express();
847
- *
848
- * app.registerApp(app);
846
+ * // returns the exact same `express.App` type back to you!
847
+ * const app = Sapling.registerApp(express());
849
848
  * ```
850
849
  */
851
850
  static registerApp(app: e.Express): e.Express;
852
- static onStartup(): void;
851
+ static onPostStartup(): void;
853
852
  /**
854
853
  * Serialize a value into a JSON string.
855
854
  *
@@ -1097,13 +1096,14 @@ declare const DefaultSwaggerMiddleware: {
1097
1096
  type HealthCheck = () => boolean | Promise<boolean>;
1098
1097
  declare class HealthRegistrar {
1099
1098
  private _checks;
1100
- private _sealed;
1099
+ private _ready;
1101
1100
  constructor();
1102
1101
  add(healthCheck: HealthCheck): void;
1103
1102
  /**
1104
- * @internal used by Sapling library
1103
+ * @internal used by Sapling library, used to determine once all
1104
+ * checks have been registered and server is, at the very least, alive.
1105
1105
  */
1106
- _seal(): void;
1106
+ _markReady(): void;
1107
1107
  check(): Promise<boolean>;
1108
1108
  }
1109
1109
  //#endregion
package/dist/index.mjs CHANGED
@@ -376,22 +376,23 @@ function __decorate(decorators, target, key, desc) {
376
376
  //#region src/middleware/health/registrar.ts
377
377
  let HealthRegistrar = class HealthRegistrar {
378
378
  _checks;
379
- _sealed;
379
+ _ready;
380
380
  constructor() {
381
381
  this._checks = [];
382
- this._sealed = false;
382
+ this._ready = false;
383
383
  }
384
384
  add(healthCheck) {
385
385
  this._checks.push(healthCheck);
386
386
  }
387
387
  /**
388
- * @internal used by Sapling library
388
+ * @internal used by Sapling library, used to determine once all
389
+ * checks have been registered and server is, at the very least, alive.
389
390
  */
390
- _seal() {
391
- this._sealed = true;
391
+ _markReady() {
392
+ this._ready = true;
392
393
  }
393
394
  async check() {
394
- if (!this._sealed) return false;
395
+ if (!this._ready) return false;
395
396
  return (await Promise.all(this._checks.map((c) => c()))).every((c) => c === true);
396
397
  }
397
398
  };
@@ -469,9 +470,8 @@ var Sapling = class Sapling {
469
470
  * import { Sapling } from "@tahminator/sapling";
470
471
  * import express from "express";
471
472
  *
472
- * const app = express();
473
- *
474
- * app.registerApp(app);
473
+ * // returns the exact same `express.App` type back to you!
474
+ * const app = Sapling.registerApp(express());
475
475
  * ```
476
476
  */
477
477
  static registerApp(app) {
@@ -483,7 +483,7 @@ var Sapling = class Sapling {
483
483
  return function(...args) {
484
484
  const server = originalListen.apply(target, args);
485
485
  server.once("listening", () => {
486
- Sapling.onStartup();
486
+ Sapling.onPostStartup();
487
487
  console.log("Sapling successfully initialized post-startup hooks on server start");
488
488
  });
489
489
  return server;
@@ -492,8 +492,8 @@ var Sapling = class Sapling {
492
492
  return Reflect.get(target, prop, receiver);
493
493
  } });
494
494
  }
495
- static onStartup() {
496
- _InjectableRegistry.get(HealthRegistrar)?.seal();
495
+ static onPostStartup() {
496
+ _InjectableRegistry.get(HealthRegistrar)?._markReady();
497
497
  }
498
498
  /**
499
499
  * Serialize a value into a JSON string.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tahminator/sapling",
3
- "version": "2.1.0-beta.a2de2fb9",
3
+ "version": "2.1.0-beta.bcb66b15",
4
4
  "author": "Tahmid Ahmed",
5
5
  "description": "A library to help you write cleaner Express.js code",
6
6
  "repository": {