@catbee/utils 2.0.3 → 2.0.5

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/server/index.d.ts CHANGED
@@ -22,7 +22,6 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import * as prom_client from 'prom-client';
26
25
  import express, { Express, Router } from 'express';
27
26
  import http from 'node:http';
28
27
  import https from 'node:https';
@@ -39,14 +38,13 @@ declare const DependencyErrors: {
39
38
  'express-rate-limit': string;
40
39
  'cookie-parser': string;
41
40
  '@scalar/express-api-reference': string;
42
- 'prom-client': string;
43
41
  };
44
42
  /**
45
43
  * Production-ready Express server with enterprise features.
46
44
  *
47
45
  * Core Features:
48
46
  * - Security: Helmet, CORS, rate limiting, timeouts
49
- * - Monitoring: Request logs, metrics, health checks
47
+ * - Monitoring: Request logs, health checks
50
48
  * - Performance: Compression, caching, static files
51
49
  * - Reliability: Graceful shutdown, error handling
52
50
  * - Developer UX: OpenAPI docs, debugging tools
@@ -56,8 +54,6 @@ declare const DependencyErrors: {
56
54
  * Includes K8s readiness probes and zero-downtime support.
57
55
  */
58
56
  declare class ExpressServer {
59
- /** Prometheus client registry for metrics collection */
60
- private readonly register;
61
57
  /** HTTP server instance (null when not running) */
62
58
  protected server: http.Server | https.Server | null;
63
59
  /** Merged configuration with defaults applied */
@@ -76,16 +72,13 @@ declare class ExpressServer {
76
72
  private readonly connections;
77
73
  /** Flag indicating if the server is shutting down */
78
74
  private isShuttingDown;
75
+ /** Flag indicating if graceful shutdown handlers are registered */
76
+ private gracefulShutdownRegistered;
79
77
  /**
80
78
  * Collection of registered health check functions.
81
79
  * These are executed when the health check endpoint is accessed.
82
80
  */
83
81
  private readonly healthChecks;
84
- /** Prometheus metrics for monitoring */
85
- private readonly requestCounter?;
86
- private readonly routeTimings?;
87
- private readonly requestSizes?;
88
- private readonly clientIPs?;
89
82
  /** Promise that resolves when initialization (middleware + routes) is complete */
90
83
  private readonly initPromise;
91
84
  /**
@@ -101,7 +94,6 @@ declare class ExpressServer {
101
94
  *
102
95
  * Default Monitoring:
103
96
  * - Request/Response logging
104
- * - Prometheus metrics
105
97
  * - Health checks
106
98
  * - Request tracing
107
99
  */
@@ -186,15 +178,11 @@ declare class ExpressServer {
186
178
  * Set up OpenAPI documentation middleware.
187
179
  */
188
180
  private setupOpenApiMiddleware;
189
- /**
190
- * Set up metrics tracking middleware.
191
- */
192
- private setupMetricsMiddleware;
193
181
  /**
194
182
  * Configure server routes and error handling.
195
183
  * Sets up in following order:
196
184
  *
197
- * 1. Built-in routes (health, metrics)
185
+ * 1. Built-in routes (health)
198
186
  * 2. Application routes
199
187
  * 3. 404 handler
200
188
  * 4. Error handler
@@ -309,6 +297,11 @@ declare class ExpressServer {
309
297
  * @param signals Array of process signals to listen for (default: SIGINT, SIGTERM)
310
298
  */
311
299
  enableGracefulShutdown(signals?: NodeJS.Signals[]): this;
300
+ /**
301
+ * Destroy all active connections (gracefully if possible).
302
+ * If a connection does not close cleanly, it will be force-destroyed.
303
+ */
304
+ private destroyConnections;
312
305
  /**
313
306
  * Set an externally created base router.
314
307
  * This will override the internal rootRouter.
@@ -351,12 +344,6 @@ declare class ExpressServer {
351
344
  * @returns This instance for method chaining
352
345
  */
353
346
  useMiddleware(...middlewares: express.RequestHandler[]): this;
354
- /**
355
- * Get Prometheus registry (to add custom counters/histograms)
356
- *
357
- * @return {*} {client.Registry}
358
- */
359
- getMetricsRegistry(): typeof prom_client.Registry;
360
347
  /**
361
348
  * Get server configuration
362
349
  *
@@ -445,15 +432,9 @@ declare class ExpressServer {
445
432
  */
446
433
  private formatHostForUrl;
447
434
  private normalizePath;
448
- private normalizeRouteForMetrics;
449
- /**
450
- * Destroy all active connections (gracefully if possible).
451
- * If a connection does not close cleanly, it will be force-destroyed.
452
- */
453
- private destroyConnections;
454
435
  private validateHttpsFiles;
455
436
  private hasBuildMarker;
456
- private throwDependancyError;
437
+ private throwDependencyError;
457
438
  }
458
439
 
459
440
  /**
@@ -675,35 +656,6 @@ declare class ServerConfigBuilder {
675
656
  * @returns The builder instance for chaining
676
657
  */
677
658
  disableRequestLogging(): this;
678
- /**
679
- * Configures server metrics collection and endpoints.
680
- *
681
- * @param opts - Metrics configuration options
682
- * @returns The builder instance for chaining
683
- * @default - { enable: false, path: '/metrics', withGlobalPrefix: false }
684
- *
685
- * @example
686
- * ```typescript
687
- * builder.withMetrics({
688
- * enable: true,
689
- * path: '/metrics'
690
- * })
691
- * ```
692
- */
693
- withMetrics(opts: Partial<NonNullable<CatbeeServerConfig['metrics']>>): this;
694
- /**
695
- * Enables Prometheus metrics collection and endpoint
696
- *
697
- * @param opts - Optional metrics configuration
698
- * @returns The builder instance for chaining
699
- */
700
- enableMetrics(opts?: Omit<Partial<NonNullable<CatbeeServerConfig['metrics']>>, 'enable'>): this;
701
- /**
702
- * Disables Prometheus metrics
703
- *
704
- * @returns The builder instance for chaining
705
- */
706
- disableMetrics(): this;
707
659
  /**
708
660
  * Configures server health check endpoint.
709
661
  *
@@ -720,6 +672,17 @@ declare class ServerConfigBuilder {
720
672
  * ```
721
673
  */
722
674
  withHealthCheck(opts: Partial<NonNullable<CatbeeServerConfig['healthCheck']>>): this;
675
+ /**
676
+ * Enables health check endpoint with default or custom settings
677
+ * @param opts - Optional health check configuration
678
+ * @returns The builder instance for chaining
679
+ *
680
+ * @example
681
+ * ```typescript
682
+ * builder.disableHealthCheck()
683
+ * ```
684
+ */
685
+ disableHealthCheck(): this;
723
686
  /**
724
687
  * Configures OpenAPI/Swagger documentation for the API.
725
688
  *
@@ -731,7 +694,7 @@ declare class ServerConfigBuilder {
731
694
  * ```typescript
732
695
  * builder.withOpenApi({
733
696
  * enable: true,
734
- * path: '/api-docs',
697
+ * mountPath: '/api-docs',
735
698
  * filePath: './openapi.yaml'
736
699
  * })
737
700
  * ```