@tahminator/sapling 2.1.0-beta.6ea2cd3e → 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
@@ -406,11 +406,6 @@ let HealthRegistrar = class HealthRegistrar {
406
406
  this._checks = [];
407
407
  this._ready = false;
408
408
  }
409
- /**
410
- * Add a health check.
411
- *
412
- * Health checks will be used to determine whether service can service traffic or not (a.k.a `liveness`).
413
- */
414
409
  add(healthCheck) {
415
410
  this._checks.push(healthCheck);
416
411
  }
@@ -432,10 +427,7 @@ HealthRegistrar = __decorate([Injectable()], HealthRegistrar);
432
427
  const _settings = {
433
428
  serialize: JSON.stringify,
434
429
  deserialize: JSON.parse,
435
- health: {
436
- ready: { path: "/up" },
437
- live: { path: "/live" }
438
- },
430
+ health: { path: "/up" },
439
431
  doc: {
440
432
  openApiPath: "/openapi.json",
441
433
  swaggerPath: "/swagger.html",
@@ -567,59 +559,37 @@ var Sapling = class Sapling {
567
559
  /**
568
560
  * Modify extra settings
569
561
  */
570
- static Extras = {
562
+ static Extras = {
563
+ /**
564
+ * Modify default settings applied to OpenAPI & Swagger
565
+ */
566
+ swaggerAndOpenApi: {
571
567
  /**
572
- * Modify default settings applied to OpenAPI & Swagger
568
+ * Set base OpenAPI metadata values.
569
+ *
570
+ * @default { title: "API", version: "1.0.0" }
573
571
  */
574
- swaggerAndOpenApi: {
575
- /**
576
- * Set base OpenAPI metadata values.
577
- *
578
- * @default { title: "API", version: "1.0.0" }
579
- */
580
- setMetadata(metadata) {
581
- _settings.doc.metadata = metadata;
582
- },
583
- /**
584
- * change default endpoint that will serve OpenAPI spec.
585
- * Swagger will also load this endpoint on load.
586
- *
587
- * @default `/openapi.json`
588
- */
589
- setOpenApiPath(path) {
590
- _settings.doc.openApiPath = path;
591
- },
592
- /**
593
- * change Swagger endpoint.
594
- *
595
- * @default `/swagger.html`
596
- */
597
- setSwaggerPath(path) {
598
- _settings.doc.swaggerPath = path;
599
- }
572
+ setMetadata(metadata) {
573
+ _settings.doc.metadata = metadata;
600
574
  },
601
575
  /**
602
- * Modify default settings applied to health / readiness / liveness.
576
+ * change default endpoint that will serve OpenAPI spec.
577
+ * Swagger will also load this endpoint on load.
578
+ *
579
+ * @default `/openapi.json`
603
580
  */
604
- health: {
605
- /**
606
- * change default endpoint that ready endpoint will be served on.
607
- *
608
- * @default `/up`
609
- */
610
- setReadyPath(path) {
611
- _settings.health.ready.path = path;
612
- },
613
- /**
614
- * change default endpoint that live endpoint will be served on.
615
- *
616
- * @default `/live`
617
- */
618
- setLivePath(path) {
619
- _settings.health.live.path = path;
620
- }
581
+ setOpenApiPath(path) {
582
+ _settings.doc.openApiPath = path;
583
+ },
584
+ /**
585
+ * change Swagger endpoint.
586
+ *
587
+ * @default `/swagger.html`
588
+ */
589
+ setSwaggerPath(path) {
590
+ _settings.doc.swaggerPath = path;
621
591
  }
622
- };
592
+ } };
623
593
  /**
624
594
  * This method can be used in a `@MiddlewareClass` to register any libraries
625
595
  * that expect you to register multiple registers at once. An example is `swagger-ui-express`
@@ -1212,17 +1182,12 @@ let DefaultHealthMiddleware = class DefaultHealthMiddleware {
1212
1182
  constructor(healthRegistrar) {
1213
1183
  this.healthRegistrar = healthRegistrar;
1214
1184
  }
1215
- async readiness(_request, _response, _next) {
1216
- const up = await this.healthRegistrar.check();
1217
- return ResponseEntity.ok().body({ up });
1218
- }
1219
- async liveness(_request, _response, _next) {
1185
+ async serve(_request, _response, _next) {
1220
1186
  const up = await this.healthRegistrar.check();
1221
1187
  return ResponseEntity.ok().body({ up });
1222
1188
  }
1223
1189
  };
1224
- __decorate([GET(_settings.health.ready.path)], DefaultHealthMiddleware.prototype, "readiness", null);
1225
- __decorate([GET(_settings.health.live.path)], DefaultHealthMiddleware.prototype, "liveness", null);
1190
+ __decorate([GET(_settings.health.path)], DefaultHealthMiddleware.prototype, "serve", null);
1226
1191
  DefaultHealthMiddleware = __decorate([MiddlewareClass({ deps: [HealthRegistrar] })], DefaultHealthMiddleware);
1227
1192
  //#endregion
1228
1193
  exports.Controller = Controller;
package/dist/index.d.cts CHANGED
@@ -795,12 +795,7 @@ type Settings = {
795
795
  serialize: (value: any) => string;
796
796
  deserialize: (value: string) => any;
797
797
  health: {
798
- ready: {
799
- path: string;
800
- };
801
- live: {
802
- path: string;
803
- };
798
+ path: string;
804
799
  };
805
800
  doc: {
806
801
  openApiPath: string;
@@ -910,23 +905,6 @@ declare class Sapling {
910
905
  */
911
906
  setSwaggerPath(this: void, path: string): void;
912
907
  };
913
- /**
914
- * Modify default settings applied to health / readiness / liveness.
915
- */
916
- health: {
917
- /**
918
- * change default endpoint that ready endpoint will be served on.
919
- *
920
- * @default `/up`
921
- */
922
- setReadyPath(this: void, path: string): void;
923
- /**
924
- * change default endpoint that live endpoint will be served on.
925
- *
926
- * @default `/live`
927
- */
928
- setLivePath(this: void, path: string): void;
929
- };
930
908
  };
931
909
  /**
932
910
  * This method can be used in a `@MiddlewareClass` to register any libraries
@@ -1120,11 +1098,6 @@ declare class HealthRegistrar {
1120
1098
  private _checks;
1121
1099
  private _ready;
1122
1100
  constructor();
1123
- /**
1124
- * Add a health check.
1125
- *
1126
- * Health checks will be used to determine whether service can service traffic or not (a.k.a `liveness`).
1127
- */
1128
1101
  add(healthCheck: HealthCheck): void;
1129
1102
  /**
1130
1103
  * @internal used by Sapling library, used to determine once all
@@ -1135,19 +1108,10 @@ declare class HealthRegistrar {
1135
1108
  }
1136
1109
  //#endregion
1137
1110
  //#region src/middleware/default/health/index.d.ts
1138
- /**
1139
- * Enable the serving of `ready` and `live` endpoints.
1140
- *
1141
- * Configure any middleware-specific settings with `Sapling.Extras.health`
1142
- * ```
1143
- */
1144
1111
  declare class DefaultHealthMiddleware {
1145
1112
  private readonly healthRegistrar;
1146
1113
  constructor(healthRegistrar: HealthRegistrar);
1147
- readiness(_request: Request, _response: Response, _next: NextFunction): Promise<ResponseEntity<{
1148
- up: boolean;
1149
- }>>;
1150
- liveness(_request: Request, _response: Response, _next: NextFunction): Promise<ResponseEntity<{
1114
+ serve(_request: Request, _response: Response, _next: NextFunction): Promise<ResponseEntity<{
1151
1115
  up: boolean;
1152
1116
  }>>;
1153
1117
  }
package/dist/index.d.mts CHANGED
@@ -795,12 +795,7 @@ type Settings = {
795
795
  serialize: (value: any) => string;
796
796
  deserialize: (value: string) => any;
797
797
  health: {
798
- ready: {
799
- path: string;
800
- };
801
- live: {
802
- path: string;
803
- };
798
+ path: string;
804
799
  };
805
800
  doc: {
806
801
  openApiPath: string;
@@ -910,23 +905,6 @@ declare class Sapling {
910
905
  */
911
906
  setSwaggerPath(this: void, path: string): void;
912
907
  };
913
- /**
914
- * Modify default settings applied to health / readiness / liveness.
915
- */
916
- health: {
917
- /**
918
- * change default endpoint that ready endpoint will be served on.
919
- *
920
- * @default `/up`
921
- */
922
- setReadyPath(this: void, path: string): void;
923
- /**
924
- * change default endpoint that live endpoint will be served on.
925
- *
926
- * @default `/live`
927
- */
928
- setLivePath(this: void, path: string): void;
929
- };
930
908
  };
931
909
  /**
932
910
  * This method can be used in a `@MiddlewareClass` to register any libraries
@@ -1120,11 +1098,6 @@ declare class HealthRegistrar {
1120
1098
  private _checks;
1121
1099
  private _ready;
1122
1100
  constructor();
1123
- /**
1124
- * Add a health check.
1125
- *
1126
- * Health checks will be used to determine whether service can service traffic or not (a.k.a `liveness`).
1127
- */
1128
1101
  add(healthCheck: HealthCheck): void;
1129
1102
  /**
1130
1103
  * @internal used by Sapling library, used to determine once all
@@ -1135,19 +1108,10 @@ declare class HealthRegistrar {
1135
1108
  }
1136
1109
  //#endregion
1137
1110
  //#region src/middleware/default/health/index.d.ts
1138
- /**
1139
- * Enable the serving of `ready` and `live` endpoints.
1140
- *
1141
- * Configure any middleware-specific settings with `Sapling.Extras.health`
1142
- * ```
1143
- */
1144
1111
  declare class DefaultHealthMiddleware {
1145
1112
  private readonly healthRegistrar;
1146
1113
  constructor(healthRegistrar: HealthRegistrar);
1147
- readiness(_request: Request, _response: Response, _next: NextFunction): Promise<ResponseEntity<{
1148
- up: boolean;
1149
- }>>;
1150
- liveness(_request: Request, _response: Response, _next: NextFunction): Promise<ResponseEntity<{
1114
+ serve(_request: Request, _response: Response, _next: NextFunction): Promise<ResponseEntity<{
1151
1115
  up: boolean;
1152
1116
  }>>;
1153
1117
  }
package/dist/index.mjs CHANGED
@@ -381,11 +381,6 @@ let HealthRegistrar = class HealthRegistrar {
381
381
  this._checks = [];
382
382
  this._ready = false;
383
383
  }
384
- /**
385
- * Add a health check.
386
- *
387
- * Health checks will be used to determine whether service can service traffic or not (a.k.a `liveness`).
388
- */
389
384
  add(healthCheck) {
390
385
  this._checks.push(healthCheck);
391
386
  }
@@ -407,10 +402,7 @@ HealthRegistrar = __decorate([Injectable()], HealthRegistrar);
407
402
  const _settings = {
408
403
  serialize: JSON.stringify,
409
404
  deserialize: JSON.parse,
410
- health: {
411
- ready: { path: "/up" },
412
- live: { path: "/live" }
413
- },
405
+ health: { path: "/up" },
414
406
  doc: {
415
407
  openApiPath: "/openapi.json",
416
408
  swaggerPath: "/swagger.html",
@@ -542,59 +534,37 @@ var Sapling = class Sapling {
542
534
  /**
543
535
  * Modify extra settings
544
536
  */
545
- static Extras = {
537
+ static Extras = {
538
+ /**
539
+ * Modify default settings applied to OpenAPI & Swagger
540
+ */
541
+ swaggerAndOpenApi: {
546
542
  /**
547
- * Modify default settings applied to OpenAPI & Swagger
543
+ * Set base OpenAPI metadata values.
544
+ *
545
+ * @default { title: "API", version: "1.0.0" }
548
546
  */
549
- swaggerAndOpenApi: {
550
- /**
551
- * Set base OpenAPI metadata values.
552
- *
553
- * @default { title: "API", version: "1.0.0" }
554
- */
555
- setMetadata(metadata) {
556
- _settings.doc.metadata = metadata;
557
- },
558
- /**
559
- * change default endpoint that will serve OpenAPI spec.
560
- * Swagger will also load this endpoint on load.
561
- *
562
- * @default `/openapi.json`
563
- */
564
- setOpenApiPath(path) {
565
- _settings.doc.openApiPath = path;
566
- },
567
- /**
568
- * change Swagger endpoint.
569
- *
570
- * @default `/swagger.html`
571
- */
572
- setSwaggerPath(path) {
573
- _settings.doc.swaggerPath = path;
574
- }
547
+ setMetadata(metadata) {
548
+ _settings.doc.metadata = metadata;
575
549
  },
576
550
  /**
577
- * Modify default settings applied to health / readiness / liveness.
551
+ * change default endpoint that will serve OpenAPI spec.
552
+ * Swagger will also load this endpoint on load.
553
+ *
554
+ * @default `/openapi.json`
578
555
  */
579
- health: {
580
- /**
581
- * change default endpoint that ready endpoint will be served on.
582
- *
583
- * @default `/up`
584
- */
585
- setReadyPath(path) {
586
- _settings.health.ready.path = path;
587
- },
588
- /**
589
- * change default endpoint that live endpoint will be served on.
590
- *
591
- * @default `/live`
592
- */
593
- setLivePath(path) {
594
- _settings.health.live.path = path;
595
- }
556
+ setOpenApiPath(path) {
557
+ _settings.doc.openApiPath = path;
558
+ },
559
+ /**
560
+ * change Swagger endpoint.
561
+ *
562
+ * @default `/swagger.html`
563
+ */
564
+ setSwaggerPath(path) {
565
+ _settings.doc.swaggerPath = path;
596
566
  }
597
- };
567
+ } };
598
568
  /**
599
569
  * This method can be used in a `@MiddlewareClass` to register any libraries
600
570
  * that expect you to register multiple registers at once. An example is `swagger-ui-express`
@@ -1187,17 +1157,12 @@ let DefaultHealthMiddleware = class DefaultHealthMiddleware {
1187
1157
  constructor(healthRegistrar) {
1188
1158
  this.healthRegistrar = healthRegistrar;
1189
1159
  }
1190
- async readiness(_request, _response, _next) {
1191
- const up = await this.healthRegistrar.check();
1192
- return ResponseEntity.ok().body({ up });
1193
- }
1194
- async liveness(_request, _response, _next) {
1160
+ async serve(_request, _response, _next) {
1195
1161
  const up = await this.healthRegistrar.check();
1196
1162
  return ResponseEntity.ok().body({ up });
1197
1163
  }
1198
1164
  };
1199
- __decorate([GET(_settings.health.ready.path)], DefaultHealthMiddleware.prototype, "readiness", null);
1200
- __decorate([GET(_settings.health.live.path)], DefaultHealthMiddleware.prototype, "liveness", null);
1165
+ __decorate([GET(_settings.health.path)], DefaultHealthMiddleware.prototype, "serve", null);
1201
1166
  DefaultHealthMiddleware = __decorate([MiddlewareClass({ deps: [HealthRegistrar] })], DefaultHealthMiddleware);
1202
1167
  //#endregion
1203
1168
  export { Controller, ControllerSchema, DELETE, DefaultBaseErrorMiddleware, DefaultHealthMiddleware, DefaultOpenApiMiddleware, DefaultParserErrorMiddleware, DefaultResponseStatusErrorMiddleware, DefaultSwaggerMiddleware, GET, HEAD, HealthRegistrar, Html404ErrorPage, HttpStatus, Injectable, Middleware, MiddlewareClass, OPTIONS, PATCH, POST, PUT, ParserError, RedirectView, RequestBody, RequestParam, RequestQuery, ResponseBody, ResponseEntity, ResponseEntityBuilder, ResponseStatusError, RouteSchema, Sapling, _ControllerRegistry, _InjectableDeps, _InjectableRegistry, _Route, _clearOpenApiRegistry, _getControllerSchema, _getOrCreateSchemaDefinition, _getRouteSchema, _getRoutes, _getValidatorSchema, _parseOrThrow, _registerController, _resolve, _saveValidatorSchema, _setControllerSchema, _setRouteSchema, _settings, generateOpenApiSpec, methodResolve, openApiGenerator };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tahminator/sapling",
3
- "version": "2.1.0-beta.6ea2cd3e",
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": {