@catbee/utils 0.0.7 → 0.0.8-rc.0
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/LICENSE +1 -1
- package/build/esm/config.js +1 -1
- package/build/esm/config.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/servers/server.builder.js +1 -1
- package/build/esm/servers/server.builder.js.map +1 -1
- package/build/esm/servers/server.d.ts +2 -2
- package/build/esm/servers/server.js +67 -20
- package/build/esm/servers/server.js.map +1 -1
- package/build/esm/types/api-response.js +1 -1
- package/build/esm/types/api-response.js.map +1 -1
- package/build/esm/types/index.js +1 -1
- package/build/esm/types/index.js.map +1 -1
- package/build/esm/types/server.js +1 -1
- package/build/esm/types/server.js.map +1 -1
- package/build/esm/utils/array.utils.js +1 -1
- package/build/esm/utils/array.utils.js.map +1 -1
- package/build/esm/utils/async.utils.js +1 -1
- package/build/esm/utils/async.utils.js.map +1 -1
- package/build/esm/utils/cache.utils.js +1 -1
- package/build/esm/utils/cache.utils.js.map +1 -1
- package/build/esm/utils/context-store.utils.js +1 -1
- package/build/esm/utils/context-store.utils.js.map +1 -1
- package/build/esm/utils/crypto.utils.js +1 -1
- package/build/esm/utils/crypto.utils.js.map +1 -1
- package/build/esm/utils/date.utils.js +1 -1
- package/build/esm/utils/date.utils.js.map +1 -1
- package/build/esm/utils/decorators.utils.js +1 -1
- package/build/esm/utils/decorators.utils.js.map +1 -1
- package/build/esm/utils/dir.utils.js +1 -1
- package/build/esm/utils/dir.utils.js.map +1 -1
- package/build/esm/utils/env.utils.js +1 -1
- package/build/esm/utils/env.utils.js.map +1 -1
- package/build/esm/utils/exception.utils.js +1 -1
- package/build/esm/utils/exception.utils.js.map +1 -1
- package/build/esm/utils/fs.utils.js +1 -1
- package/build/esm/utils/fs.utils.js.map +1 -1
- package/build/esm/utils/http-status-codes.js +1 -1
- package/build/esm/utils/http-status-codes.js.map +1 -1
- package/build/esm/utils/id.utils.js +1 -1
- package/build/esm/utils/id.utils.js.map +1 -1
- package/build/esm/utils/logger.utils.d.ts +1 -1
- package/build/esm/utils/logger.utils.js +1 -1
- package/build/esm/utils/logger.utils.js.map +1 -1
- package/build/esm/utils/middleware.utils.d.ts +17 -0
- package/build/esm/utils/middleware.utils.js +120 -1
- package/build/esm/utils/middleware.utils.js.map +1 -1
- package/build/esm/utils/obj.utils.js +1 -1
- package/build/esm/utils/obj.utils.js.map +1 -1
- package/build/esm/utils/performance.utils.js +1 -1
- package/build/esm/utils/performance.utils.js.map +1 -1
- package/build/esm/utils/request.utils.js +1 -1
- package/build/esm/utils/request.utils.js.map +1 -1
- package/build/esm/utils/response.utils.js +1 -1
- package/build/esm/utils/response.utils.js.map +1 -1
- package/build/esm/utils/stream.utils.js +1 -1
- package/build/esm/utils/stream.utils.js.map +1 -1
- package/build/esm/utils/string.utils.js +1 -1
- package/build/esm/utils/string.utils.js.map +1 -1
- package/build/esm/utils/type.utils.js +1 -1
- package/build/esm/utils/type.utils.js.map +1 -1
- package/build/esm/utils/url.utils.js +1 -1
- package/build/esm/utils/url.utils.js.map +1 -1
- package/build/esm/utils/validate.utils.js +1 -1
- package/build/esm/utils/validate.utils.js.map +1 -1
- package/build/esnext/config.js +1 -1
- package/build/esnext/config.js.map +1 -1
- package/build/esnext/index.js +1 -1
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/servers/server.builder.js +1 -1
- package/build/esnext/servers/server.builder.js.map +1 -1
- package/build/esnext/servers/server.d.ts +2 -2
- package/build/esnext/servers/server.js +66 -19
- package/build/esnext/servers/server.js.map +1 -1
- package/build/esnext/types/api-response.js +1 -1
- package/build/esnext/types/api-response.js.map +1 -1
- package/build/esnext/types/index.js +1 -1
- package/build/esnext/types/index.js.map +1 -1
- package/build/esnext/types/server.js +1 -1
- package/build/esnext/types/server.js.map +1 -1
- package/build/esnext/utils/array.utils.js +1 -1
- package/build/esnext/utils/array.utils.js.map +1 -1
- package/build/esnext/utils/async.utils.js +1 -1
- package/build/esnext/utils/async.utils.js.map +1 -1
- package/build/esnext/utils/cache.utils.js +1 -1
- package/build/esnext/utils/cache.utils.js.map +1 -1
- package/build/esnext/utils/context-store.utils.js +1 -1
- package/build/esnext/utils/context-store.utils.js.map +1 -1
- package/build/esnext/utils/crypto.utils.js +1 -1
- package/build/esnext/utils/crypto.utils.js.map +1 -1
- package/build/esnext/utils/date.utils.js +1 -1
- package/build/esnext/utils/date.utils.js.map +1 -1
- package/build/esnext/utils/decorators.utils.js +1 -1
- package/build/esnext/utils/decorators.utils.js.map +1 -1
- package/build/esnext/utils/dir.utils.js +1 -1
- package/build/esnext/utils/dir.utils.js.map +1 -1
- package/build/esnext/utils/env.utils.js +1 -1
- package/build/esnext/utils/env.utils.js.map +1 -1
- package/build/esnext/utils/exception.utils.js +1 -1
- package/build/esnext/utils/exception.utils.js.map +1 -1
- package/build/esnext/utils/fs.utils.js +1 -1
- package/build/esnext/utils/fs.utils.js.map +1 -1
- package/build/esnext/utils/http-status-codes.js +1 -1
- package/build/esnext/utils/http-status-codes.js.map +1 -1
- package/build/esnext/utils/id.utils.js +1 -1
- package/build/esnext/utils/id.utils.js.map +1 -1
- package/build/esnext/utils/logger.utils.d.ts +1 -1
- package/build/esnext/utils/logger.utils.js +1 -1
- package/build/esnext/utils/logger.utils.js.map +1 -1
- package/build/esnext/utils/middleware.utils.d.ts +17 -0
- package/build/esnext/utils/middleware.utils.js +38 -1
- package/build/esnext/utils/middleware.utils.js.map +1 -1
- package/build/esnext/utils/obj.utils.js +1 -1
- package/build/esnext/utils/obj.utils.js.map +1 -1
- package/build/esnext/utils/performance.utils.js +1 -1
- package/build/esnext/utils/performance.utils.js.map +1 -1
- package/build/esnext/utils/request.utils.js +1 -1
- package/build/esnext/utils/request.utils.js.map +1 -1
- package/build/esnext/utils/response.utils.js +1 -1
- package/build/esnext/utils/response.utils.js.map +1 -1
- package/build/esnext/utils/stream.utils.js +1 -1
- package/build/esnext/utils/stream.utils.js.map +1 -1
- package/build/esnext/utils/string.utils.js +1 -1
- package/build/esnext/utils/string.utils.js.map +1 -1
- package/build/esnext/utils/type.utils.js +1 -1
- package/build/esnext/utils/type.utils.js.map +1 -1
- package/build/esnext/utils/url.utils.js +1 -1
- package/build/esnext/utils/url.utils.js.map +1 -1
- package/build/esnext/utils/validate.utils.js +1 -1
- package/build/esnext/utils/validate.utils.js.map +1 -1
- package/build/src/config.js +1 -1
- package/build/src/config.js.map +1 -1
- package/build/src/index.js +1 -1
- package/build/src/index.js.map +1 -1
- package/build/src/servers/server.builder.js +1 -1
- package/build/src/servers/server.builder.js.map +1 -1
- package/build/src/servers/server.d.ts +2 -2
- package/build/src/servers/server.js +76 -62
- package/build/src/servers/server.js.map +1 -1
- package/build/src/types/api-response.js +1 -1
- package/build/src/types/api-response.js.map +1 -1
- package/build/src/types/index.js +1 -1
- package/build/src/types/index.js.map +1 -1
- package/build/src/types/server.js +1 -1
- package/build/src/types/server.js.map +1 -1
- package/build/src/utils/array.utils.js +1 -1
- package/build/src/utils/array.utils.js.map +1 -1
- package/build/src/utils/async.utils.js +1 -1
- package/build/src/utils/async.utils.js.map +1 -1
- package/build/src/utils/cache.utils.js +1 -1
- package/build/src/utils/cache.utils.js.map +1 -1
- package/build/src/utils/context-store.utils.js +1 -1
- package/build/src/utils/context-store.utils.js.map +1 -1
- package/build/src/utils/crypto.utils.js +1 -1
- package/build/src/utils/crypto.utils.js.map +1 -1
- package/build/src/utils/date.utils.js +1 -1
- package/build/src/utils/date.utils.js.map +1 -1
- package/build/src/utils/decorators.utils.js +1 -1
- package/build/src/utils/decorators.utils.js.map +1 -1
- package/build/src/utils/dir.utils.js +1 -1
- package/build/src/utils/dir.utils.js.map +1 -1
- package/build/src/utils/env.utils.js +1 -1
- package/build/src/utils/env.utils.js.map +1 -1
- package/build/src/utils/exception.utils.js +1 -1
- package/build/src/utils/exception.utils.js.map +1 -1
- package/build/src/utils/fs.utils.js +1 -1
- package/build/src/utils/fs.utils.js.map +1 -1
- package/build/src/utils/http-status-codes.js +1 -1
- package/build/src/utils/http-status-codes.js.map +1 -1
- package/build/src/utils/id.utils.js +1 -1
- package/build/src/utils/id.utils.js.map +1 -1
- package/build/src/utils/logger.utils.d.ts +1 -1
- package/build/src/utils/logger.utils.js +1 -1
- package/build/src/utils/logger.utils.js.map +1 -1
- package/build/src/utils/middleware.utils.d.ts +17 -0
- package/build/src/utils/middleware.utils.js +39 -1
- package/build/src/utils/middleware.utils.js.map +1 -1
- package/build/src/utils/obj.utils.js +1 -1
- package/build/src/utils/obj.utils.js.map +1 -1
- package/build/src/utils/performance.utils.js +1 -1
- package/build/src/utils/performance.utils.js.map +1 -1
- package/build/src/utils/request.utils.js +1 -1
- package/build/src/utils/request.utils.js.map +1 -1
- package/build/src/utils/response.utils.js +1 -1
- package/build/src/utils/response.utils.js.map +1 -1
- package/build/src/utils/stream.utils.js +1 -1
- package/build/src/utils/stream.utils.js.map +1 -1
- package/build/src/utils/string.utils.js +1 -1
- package/build/src/utils/string.utils.js.map +1 -1
- package/build/src/utils/type.utils.js +1 -1
- package/build/src/utils/type.utils.js.map +1 -1
- package/build/src/utils/url.utils.js +1 -1
- package/build/src/utils/url.utils.js.map +1 -1
- package/build/src/utils/validate.utils.js +1 -1
- package/build/src/utils/validate.utils.js.map +1 -1
- package/package.json +17 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.builder.js","sourceRoot":"","sources":["../../../src/servers/server.builder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,kDAAkD;AAElD,sCAAgD;AAChD,4DAAiD;AAEjD;;;;;;;;;;;;;;;GAeG;AAEU,QAAA,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAEtE,MAAa,mBAAmB;IAAhC;QACU,WAAM,GAA0B,EAAE,CAAC;IAupB7C,CAAC;IArpBC;;;;;;OAMG;IACK,YAAY,CAAC,IAAY;QAC/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AAC;IAEO,WAAW,CAA+B,GAAM,EAAE,KAA4C;QACpG,MAAM,OAAO,GACX,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI;YAC/D,CAAC,CAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAkC;YACpD,CAAC,CAAC,EAAE,CAAC;QACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAA,wBAAY,EAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAiC,CAAC;IACtF,CAAC;IAEO,UAAU,CAChB,GAAM,EACN,MAAe,EACf,YAAmD,EAAE;QAErD,IAAI,CAAC,WAAW,CAAC,GAAG,kCAAO,SAAS,KAAE,MAAM,IAAG,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxpBD,kDAwpBC","sourcesContent":["/*\n * The MIT License\n *\n * Copyright (c) 2025 Catbee Technologies\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { deepObjMerge } from '../utils/obj.utils';\nimport { ServerConfig } from '../types/server';\nimport { defaultServerConfig } from '../config';\nimport { isPort } from '../utils/validate.utils';\n\n/**\n * Builder class for creating and configuring an Express server configuration.\n *\n * This class provides a fluent interface to configure all aspects of the Express server\n * including security settings, middleware, routing, and more.\n *\n * @example\n * ```typescript\n * const serverConfig = new ServerConfigBuilder()\n * .withPort(3000)\n * .withHost('localhost')\n * .enableCors()\n * .enableHelmet()\n * .build();\n * ```\n */\n\nexport const BUILD_MARKER = Symbol.for('catbee.express.server.build');\n\nexport class ServerConfigBuilder {\n private config: Partial<ServerConfig> = {};\n\n /**\n * Validates that a port number is valid and usable.\n *\n * @private\n * @param port - The port number to validate\n * @throws {Error} If port is not an integer or is outside the valid range (1-65535)\n */\n private validatePort(port: number): void {\n if (!isPort(port)) {\n throw new Error(`Port must be a valid number between 1 and 65535, got: ${port}`);\n }\n }\n\n /**\n * Sets the port the server will listen on.\n *\n * @param port - The port number (1-65535)\n * @returns The builder instance for chaining\n * @throws {Error} If port is invalid\n * @default 3000 (can be overridden via PORT env variable)\n *\n * @example\n * ```typescript\n * builder.withPort(3000)\n * ```\n */\n withPort(port: number): this {\n this.validatePort(port);\n this.config.port = port;\n return this;\n }\n\n /**\n * Sets the hostname the server will bind to.\n *\n * @param host - The hostname (e.g., 'localhost', '0.0.0.0', '127.0.0.1')\n * @returns The builder instance for chaining\n * @default '0.0.0.0' (can be overridden via HOST env variable)\n *\n * @example\n * ```typescript\n * builder.withHost('0.0.0.0') // Listen on all interfaces\n * ```\n */\n withHost(host: string): this {\n this.config.host = host;\n return this;\n }\n\n /**\n * Configures Cross-Origin Resource Sharing (CORS) for the server.\n *\n * @param opts - CORS options object or boolean (true to enable with defaults, false to disable)\n * @returns The builder instance for chaining\n * @default false (CORS is disabled by default)\n *\n * @example\n * ```typescript\n * // Enable CORS with default options\n * builder.withCors(true)\n *\n * // Configure CORS with specific options\n * builder.withCors({\n * origin: ['https://example.com'],\n * methods: ['GET', 'POST']\n * })\n * ```\n */\n withCors(opts: ServerConfig['cors']): this {\n this.config.cors = opts;\n return this;\n }\n\n /**\n * Enables CORS with default settings\n *\n * @returns The builder instance for chaining\n */\n enableCors(): this {\n return this.withCors(true);\n }\n\n /**\n * Disables CORS\n *\n * @returns The builder instance for chaining\n */\n disableCors(): this {\n return this.withCors(false);\n }\n\n /**\n * Configures the Helmet middleware for setting HTTP security headers.\n *\n * @param opts - Helmet options object or boolean (true to enable with defaults, false to disable)\n * @returns The builder instance for chaining\n * @default false (Helmet is disabled by default)\n *\n * @example\n * ```typescript\n * // Enable Helmet with default settings\n * builder.withHelmet(true)\n *\n * // Configure Helmet with specific options\n * builder.withHelmet({\n * contentSecurityPolicy: false,\n * xssFilter: true\n * })\n * ```\n */\n withHelmet(opts: ServerConfig['helmet']): this {\n this.config.helmet = opts;\n return this;\n }\n\n /**\n * Enables Helmet with default settings\n *\n * @returns The builder instance for chaining\n */\n enableHelmet(): this {\n return this.withHelmet(true);\n }\n\n /**\n * Disables Helmet\n *\n * @returns The builder instance for chaining\n */\n disableHelmet(): this {\n return this.withHelmet(false);\n }\n\n /**\n * Configures response compression middleware.\n *\n * @param opts - Compression options object or boolean (true to enable with defaults, false to disable)\n * @returns The builder instance for chaining\n * @default false (Compression is disabled by default)\n *\n * @example\n * ```typescript\n * // Enable compression with default settings\n * builder.withCompression(true)\n *\n * // Configure compression with specific options\n * builder.withCompression({\n * level: 6,\n * threshold: 1024\n * })\n * ```\n */\n withCompression(opts: ServerConfig['compression']): this {\n this.config.compression = opts;\n return this;\n }\n\n /**\n * Enables compression with default settings\n *\n * @returns The builder instance for chaining\n */\n enableCompression(): this {\n return this.withCompression(true);\n }\n\n /**\n * Disables compression\n *\n * @returns The builder instance for chaining\n */\n disableCompression(): this {\n return this.withCompression(false);\n }\n\n /**\n * Configures rate limiting to protect against brute-force attacks.\n *\n * @param opts - Rate limit configuration options\n * @returns The builder instance for chaining\n * @default { enable: false, windowMs: 15 * 60 * 1000, max: 100, message: 'Too many requests', standardHeaders: true, legacyHeaders: false }\n *\n * @example\n * ```typescript\n * builder.withRateLimit({\n * enable: true,\n * windowMs: 15 * 60 * 1000, // 15 minutes\n * max: 100 // limit each IP to 100 requests per windowMs\n * })\n * ```\n */\n withRateLimit(opts: Partial<ServerConfig['rateLimit']>): this {\n this.mergeConfig('rateLimit', opts as NonNullable<ServerConfig['rateLimit']>);\n return this;\n }\n\n /**\n * Enables rate limiting with default or custom settings\n *\n * @param opts - Optional rate limit configuration (max requests, window, etc.)\n * @returns The builder instance for chaining\n */\n enableRateLimit(opts: Omit<Partial<NonNullable<ServerConfig['rateLimit']>>, 'enable'> = {}): this {\n return this.setEnabled('rateLimit', true, opts);\n }\n\n /**\n * Disables rate limiting\n *\n * @returns The builder instance for chaining\n */\n disableRateLimit(): this {\n return this.setEnabled('rateLimit', false);\n }\n\n /**\n * Configures HTTP request logging middleware.\n *\n * @param opts - Request logging configuration options\n * @returns The builder instance for chaining\n * @default { enable: true in dev/false in prod, ignorePaths: ['/healthz', '/favicon.ico', '/metrics', '/docs', '/.well-known'], skipNotFoundRoutes: false }\n *\n * @example\n * ```typescript\n * builder.withRequestLogging({\n * enable: true,\n * ignorePaths: ['/health', '/metrics'],\n * skipNotFoundRoutes: true\n * })\n * ```\n */\n withRequestLogging(opts: Partial<NonNullable<ServerConfig['requestLogging']>>): this {\n this.mergeConfig('requestLogging', opts as NonNullable<ServerConfig['requestLogging']>);\n return this;\n }\n\n /**\n * Enables request logging with default or custom settings\n *\n * @param opts - Optional request logging configuration\n * @returns The builder instance for chaining\n */\n enableRequestLogging(opts: Omit<Partial<NonNullable<ServerConfig['requestLogging']>>, 'enable'> = {}): this {\n return this.setEnabled('requestLogging', true, opts);\n }\n\n /**\n * Disables request logging\n *\n * @returns The builder instance for chaining\n */\n disableRequestLogging(): this {\n return this.setEnabled('requestLogging', false);\n }\n\n /**\n * Configures server metrics collection and endpoints.\n *\n * @param opts - Metrics configuration options\n * @returns The builder instance for chaining\n * @default { enable: false, path: '/metrics', withGlobalPrefix: false }\n *\n * @example\n * ```typescript\n * builder.withMetrics({\n * enable: true,\n * path: '/metrics'\n * })\n * ```\n */\n withMetrics(opts: Partial<NonNullable<ServerConfig['metrics']>>): this {\n this.mergeConfig('metrics', opts as NonNullable<ServerConfig['metrics']>);\n return this;\n }\n\n /**\n * Enables Prometheus metrics collection and endpoint\n *\n * @param opts - Optional metrics configuration\n * @returns The builder instance for chaining\n */\n enableMetrics(opts: Omit<Partial<NonNullable<ServerConfig['metrics']>>, 'enable'> = {}): this {\n return this.setEnabled('metrics', true, opts);\n }\n\n /**\n * Disables Prometheus metrics\n *\n * @returns The builder instance for chaining\n */\n disableMetrics(): this {\n return this.setEnabled('metrics', false);\n }\n\n /**\n * Configures server health check endpoint.\n *\n * @param opts - Health check configuration options\n * @returns The builder instance for chaining\n * @default { path: '/healthz', detailed: true, withGlobalPrefix: false }\n *\n * @example\n * ```typescript\n * builder.withHealthCheck({\n * path: '/health',\n * detailed: true\n * })\n * ```\n */\n withHealthCheck(opts: Partial<NonNullable<ServerConfig['healthCheck']>>): this {\n this.mergeConfig('healthCheck', opts as NonNullable<ServerConfig['healthCheck']>);\n return this;\n }\n\n /**\n * Configures OpenAPI/Swagger documentation for the API.\n *\n * @param opts - OpenAPI configuration options\n * @returns The builder instance for chaining\n * @default { enable: false, mountPath: '/docs', verbose: false, withGlobalPrefix: false }\n *\n * @example\n * ```typescript\n * builder.withOpenApi({\n * enable: true,\n * path: '/api-docs',\n * filePath: './openapi.yaml'\n * })\n * ```\n */\n withOpenApi(opts: Partial<NonNullable<ServerConfig['openApi']>>): this {\n this.mergeConfig('openApi', opts as NonNullable<ServerConfig['openApi']>);\n return this;\n }\n\n /**\n * Enables OpenAPI documentation with required file path\n *\n * @param filePath - Path to OpenAPI specification file (required)\n * @param opts - Optional OpenAPI configuration\n * @returns The builder instance for chaining\n */\n enableOpenApi(\n filePath: string,\n opts: Omit<Partial<NonNullable<ServerConfig['openApi']>>, 'enable' | 'filePath'> = {}\n ): this {\n this.setEnabled('openApi', true, { filePath, ...opts });\n return this;\n }\n\n /**\n * Disables OpenAPI documentation\n *\n * @returns The builder instance for chaining\n */\n disableOpenApi(): this {\n return this.setEnabled('openApi', false);\n }\n\n /**\n * Configures the server as a microservice with versioning.\n *\n * @param opts - Microservice configuration options including app name and service version\n * @returns The builder instance for chaining\n * @default { isMicroservice: false, appName: 'express_app' }\n *\n * @example\n * ```typescript\n * builder.withMicroService({\n * appName: 'user-service',\n * serviceVersion: {\n * enable: true,\n * version: '1.2.3'\n * }\n * })\n * ```\n */\n withMicroService(opts: {\n appName: NonNullable<ServerConfig['appName']>;\n serviceVersion: Partial<NonNullable<ServerConfig['serviceVersion']>>;\n }): this {\n this.config.isMicroservice = true;\n this.config.appName = opts.appName;\n\n this.mergeConfig('serviceVersion', opts.serviceVersion as NonNullable<ServerConfig['serviceVersion']>);\n return this;\n }\n\n /**\n * Configures the trust proxy settings to determine if X-Forwarded-* headers should be trusted.\n *\n * @param opts - Trust proxy configuration options\n * @returns The builder instance for chaining\n * @default false\n *\n * @example\n * ```typescript\n * // Trust proxy headers (useful when behind a load balancer)\n * builder.withTrustProxy(true)\n * ```\n */\n withTrustProxy(opts: NonNullable<ServerConfig['trustProxy']>): this {\n this.config.trustProxy = opts;\n return this;\n }\n\n /**\n * Configures the request ID middleware for tracing requests across services.\n *\n * @param opts - Request ID configuration options\n * @returns The builder instance for chaining\n * @default { headerName: 'x-request-id', exposeHeader: true }\n *\n * @example\n * ```typescript\n * builder.withRequestId({\n * headerName: 'X-Request-Id',\n * generator: () => crypto.randomUUID()\n * })\n * ```\n */\n withRequestId(opts: Partial<NonNullable<ServerConfig['requestId']>>): this {\n this.mergeConfig('requestId', opts as NonNullable<ServerConfig['requestId']>);\n return this;\n }\n\n /**\n * Configures the response time middleware for measuring request processing times.\n *\n * @param opts - Response time configuration options\n * @returns The builder instance for chaining\n * @default { enable: false, addHeader: true, logOnComplete: false }\n *\n * @example\n * ```typescript\n * builder.withResponseTime({\n * enable: true,\n * addHeader: true,\n * logOnComplete: true\n * })\n * ```\n */\n withResponseTime(opts: Partial<NonNullable<ServerConfig['responseTime']>>): this {\n this.mergeConfig('responseTime', opts as NonNullable<ServerConfig['responseTime']>);\n return this;\n }\n\n /**\n * Enables response time tracking with default or custom settings\n *\n * @param opts - Optional response time configuration\n * @returns The builder instance for chaining\n */\n enableResponseTime(opts: Omit<Partial<NonNullable<ServerConfig['responseTime']>>, 'enable'> = {}): this {\n this.setEnabled('responseTime', true, opts);\n return this;\n }\n\n /**\n * Disables response time tracking\n *\n * @returns The builder instance for chaining\n */\n disableResponseTime(): this {\n return this.setEnabled('responseTime', false);\n }\n\n /**\n * Configures the body parser middleware options for parsing request bodies.\n *\n * @param opts - Body parser configuration options\n * @returns The builder instance for chaining\n * @default { json: { limit: '1mb' }, urlencoded: { extended: true, limit: '1mb' } }\n *\n * @example\n * ```typescript\n * builder.withBodyParser({\n * json: {\n * limit: '1mb'\n * },\n * urlencoded: {\n * extended: true,\n * limit: '1mb'\n * }\n * })\n * ```\n */\n withBodyParser(opts: NonNullable<ServerConfig['bodyParser']>): this {\n this.config.bodyParser = deepObjMerge({}, this.config.bodyParser ?? {}, opts);\n return this;\n }\n\n /**\n * Configures cookie parsing middleware.\n *\n * @param opts - Cookie parser options or boolean (true to enable with defaults, false to disable)\n * @returns The builder instance for chaining\n * @default false\n *\n * @example\n * ```typescript\n * // Enable cookie parsing with default options\n * builder.withCookies(true)\n *\n * // Enable cookie parsing with specific options\n * builder.withCookies({\n * secret: 'your-secret-key',\n * secure: true\n * })\n * ```\n */\n withCookies(opts: ServerConfig['cookieParser']): this {\n this.config.cookieParser = opts;\n return this;\n }\n\n /**\n * Adds a static folder to serve files from.\n *\n * @param folder - Static folder configuration\n * @returns The builder instance for chaining\n *\n * @example\n * ```typescript\n * builder.withStaticFolder({\n * path: '/assets',\n * directory: './public',\n * options: { maxAge: '1d' }\n * })\n * ```\n */\n withStaticFolder(folder: NonNullable<ServerConfig['staticFolders']>[number]): this {\n if (!folder.path) throw new Error('Static folder requires a path');\n const folders = [...(this.config.staticFolders ?? []), folder];\n this.config.staticFolders = Array.from(new Map(folders.map(f => [f.path, f])).values());\n return this;\n }\n\n /**\n * Sets global headers to be included in all responses.\n *\n * @param headers - Object containing header name/value pairs or functions that return values\n * @returns The builder instance for chaining\n * @default {}\n *\n * @example\n * ```typescript\n * builder.withGlobalHeaders({\n * 'X-Powered-By': 'Catbee',\n * 'Server-Time': () => new Date().toISOString()\n * })\n * ```\n */\n withGlobalHeaders(headers: NonNullable<ServerConfig['globalHeaders']>): this {\n this.mergeConfig('globalHeaders', headers);\n return this;\n }\n\n /**\n * Sets a global prefix for all routes.\n *\n * @param prefix - The prefix to prepend to all routes (e.g., '/api/v1')\n * @returns The builder instance for chaining\n * @default '/'\n *\n * @example\n * ```typescript\n * builder.withGlobalPrefix('/api/v1')\n * ```\n */\n withGlobalPrefix(prefix: string): this {\n this.config.globalPrefix = prefix;\n return this;\n }\n\n /**\n * Applies custom configuration overrides directly.\n *\n * @param overrides - Custom configuration options to merge\n * @returns The builder instance for chaining\n *\n * @example\n * ```typescript\n * builder.withCustom({\n * port: 8080,\n * customMiddleware: myMiddlewareFunction\n * })\n * ```\n */\n withCustom(overrides: Partial<ServerConfig>): this {\n this.config = deepObjMerge({}, this.config, overrides);\n return this;\n }\n\n /**\n * Configures HTTPS server options.\n *\n * @param opts - HTTPS configuration (key, cert, ca, passphrase, etc.)\n * @returns The builder instance for chaining\n *\n * @example\n * ```typescript\n * builder.withHttps({\n * key: './localhost-key.pem',\n * cert: './localhost-cert.pem'\n * })\n * ```\n */\n withHttps(opts: NonNullable<ServerConfig['https']>): this {\n this.config.https = opts;\n return this;\n }\n\n /**\n * Builds and returns the final server configuration.\n *\n * This method merges the user-specified configuration with default values,\n * ensures all sections with 'enable' flags are properly structured, and\n * produces the final configuration to be used by the server.\n *\n * @returns The complete ServerConfig object\n *\n * @example\n * ```typescript\n * const config = new ServerConfigBuilder()\n * .withPort(3000)\n * .withHost('localhost')\n * .withCors(true)\n * .build();\n * ```\n */\n build(): Readonly<ServerConfig> {\n const config = deepObjMerge({}, defaultServerConfig, this.config) as ServerConfig;\n\n // Common validation\n if (config.openApi?.enable && !config.openApi.filePath) {\n throw new Error('OpenAPI is enabled but no filePath is specified');\n }\n\n return Object.freeze({\n ...config,\n [BUILD_MARKER]: true\n });\n }\n\n private mergeConfig<K extends keyof ServerConfig>(key: K, value: Partial<NonNullable<ServerConfig[K]>>): void {\n const current =\n typeof this.config[key] === 'object' && this.config[key] !== null\n ? (this.config[key] as NonNullable<ServerConfig[K]>)\n : {};\n this.config[key] = deepObjMerge({}, current, value) as NonNullable<ServerConfig[K]>;\n }\n\n private setEnabled<K extends keyof ServerConfig>(\n key: K,\n enable: boolean,\n overrides: Partial<NonNullable<ServerConfig[K]>> = {}\n ): this {\n this.mergeConfig(key, { ...overrides, enable });\n return this;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"server.builder.js","sourceRoot":"","sources":["../../../src/servers/server.builder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,kDAAkD;AAElD,sCAAgD;AAChD,4DAAiD;AAEjD;;;;;;;;;;;;;;;GAeG;AAEU,QAAA,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAEtE,MAAa,mBAAmB;IAAhC;QACU,WAAM,GAA0B,EAAE,CAAC;IAupB7C,CAAC;IArpBC;;;;;;OAMG;IACK,YAAY,CAAC,IAAY;QAC/B,IAAI,CAAC,IAAA,uBAAM,EAAC,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,yDAAyD,IAAI,EAAE,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC,YAA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CAAC,GAAG,CAAkC;YACpD,CAAC,CAAC,EAAE,CAAC;QACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAA,wBAAY,EAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAiC,CAAC;IACtF,CAAC;IAEO,UAAU,CAChB,GAAM,EACN,MAAe,EACf,YAAmD,EAAE;QAErD,IAAI,CAAC,WAAW,CAAC,GAAG,kCAAO,SAAS,KAAE,MAAM,IAAG,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxpBD,kDAwpBC","sourcesContent":["/*\n * The MIT License\n *\n * Copyright (c) 2025 Catbee Technologies. https://catbee-utils.npm.hprasath.com/license\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { deepObjMerge } from '../utils/obj.utils';\nimport { ServerConfig } from '../types/server';\nimport { defaultServerConfig } from '../config';\nimport { isPort } from '../utils/validate.utils';\n\n/**\n * Builder class for creating and configuring an Express server configuration.\n *\n * This class provides a fluent interface to configure all aspects of the Express server\n * including security settings, middleware, routing, and more.\n *\n * @example\n * ```typescript\n * const serverConfig = new ServerConfigBuilder()\n * .withPort(3000)\n * .withHost('localhost')\n * .enableCors()\n * .enableHelmet()\n * .build();\n * ```\n */\n\nexport const BUILD_MARKER = Symbol.for('catbee.express.server.build');\n\nexport class ServerConfigBuilder {\n private config: Partial<ServerConfig> = {};\n\n /**\n * Validates that a port number is valid and usable.\n *\n * @private\n * @param port - The port number to validate\n * @throws {Error} If port is not an integer or is outside the valid range (1-65535)\n */\n private validatePort(port: number): void {\n if (!isPort(port)) {\n throw new Error(`Port must be a valid number between 1 and 65535, got: ${port}`);\n }\n }\n\n /**\n * Sets the port the server will listen on.\n *\n * @param port - The port number (1-65535)\n * @returns The builder instance for chaining\n * @throws {Error} If port is invalid\n * @default 3000 (can be overridden via PORT env variable)\n *\n * @example\n * ```typescript\n * builder.withPort(3000)\n * ```\n */\n withPort(port: number): this {\n this.validatePort(port);\n this.config.port = port;\n return this;\n }\n\n /**\n * Sets the hostname the server will bind to.\n *\n * @param host - The hostname (e.g., 'localhost', '0.0.0.0', '127.0.0.1')\n * @returns The builder instance for chaining\n * @default '0.0.0.0' (can be overridden via HOST env variable)\n *\n * @example\n * ```typescript\n * builder.withHost('0.0.0.0') // Listen on all interfaces\n * ```\n */\n withHost(host: string): this {\n this.config.host = host;\n return this;\n }\n\n /**\n * Configures Cross-Origin Resource Sharing (CORS) for the server.\n *\n * @param opts - CORS options object or boolean (true to enable with defaults, false to disable)\n * @returns The builder instance for chaining\n * @default false (CORS is disabled by default)\n *\n * @example\n * ```typescript\n * // Enable CORS with default options\n * builder.withCors(true)\n *\n * // Configure CORS with specific options\n * builder.withCors({\n * origin: ['https://example.com'],\n * methods: ['GET', 'POST']\n * })\n * ```\n */\n withCors(opts: ServerConfig['cors']): this {\n this.config.cors = opts;\n return this;\n }\n\n /**\n * Enables CORS with default settings\n *\n * @returns The builder instance for chaining\n */\n enableCors(): this {\n return this.withCors(true);\n }\n\n /**\n * Disables CORS\n *\n * @returns The builder instance for chaining\n */\n disableCors(): this {\n return this.withCors(false);\n }\n\n /**\n * Configures the Helmet middleware for setting HTTP security headers.\n *\n * @param opts - Helmet options object or boolean (true to enable with defaults, false to disable)\n * @returns The builder instance for chaining\n * @default false (Helmet is disabled by default)\n *\n * @example\n * ```typescript\n * // Enable Helmet with default settings\n * builder.withHelmet(true)\n *\n * // Configure Helmet with specific options\n * builder.withHelmet({\n * contentSecurityPolicy: false,\n * xssFilter: true\n * })\n * ```\n */\n withHelmet(opts: ServerConfig['helmet']): this {\n this.config.helmet = opts;\n return this;\n }\n\n /**\n * Enables Helmet with default settings\n *\n * @returns The builder instance for chaining\n */\n enableHelmet(): this {\n return this.withHelmet(true);\n }\n\n /**\n * Disables Helmet\n *\n * @returns The builder instance for chaining\n */\n disableHelmet(): this {\n return this.withHelmet(false);\n }\n\n /**\n * Configures response compression middleware.\n *\n * @param opts - Compression options object or boolean (true to enable with defaults, false to disable)\n * @returns The builder instance for chaining\n * @default false (Compression is disabled by default)\n *\n * @example\n * ```typescript\n * // Enable compression with default settings\n * builder.withCompression(true)\n *\n * // Configure compression with specific options\n * builder.withCompression({\n * level: 6,\n * threshold: 1024\n * })\n * ```\n */\n withCompression(opts: ServerConfig['compression']): this {\n this.config.compression = opts;\n return this;\n }\n\n /**\n * Enables compression with default settings\n *\n * @returns The builder instance for chaining\n */\n enableCompression(): this {\n return this.withCompression(true);\n }\n\n /**\n * Disables compression\n *\n * @returns The builder instance for chaining\n */\n disableCompression(): this {\n return this.withCompression(false);\n }\n\n /**\n * Configures rate limiting to protect against brute-force attacks.\n *\n * @param opts - Rate limit configuration options\n * @returns The builder instance for chaining\n * @default { enable: false, windowMs: 15 * 60 * 1000, max: 100, message: 'Too many requests', standardHeaders: true, legacyHeaders: false }\n *\n * @example\n * ```typescript\n * builder.withRateLimit({\n * enable: true,\n * windowMs: 15 * 60 * 1000, // 15 minutes\n * max: 100 // limit each IP to 100 requests per windowMs\n * })\n * ```\n */\n withRateLimit(opts: Partial<ServerConfig['rateLimit']>): this {\n this.mergeConfig('rateLimit', opts as NonNullable<ServerConfig['rateLimit']>);\n return this;\n }\n\n /**\n * Enables rate limiting with default or custom settings\n *\n * @param opts - Optional rate limit configuration (max requests, window, etc.)\n * @returns The builder instance for chaining\n */\n enableRateLimit(opts: Omit<Partial<NonNullable<ServerConfig['rateLimit']>>, 'enable'> = {}): this {\n return this.setEnabled('rateLimit', true, opts);\n }\n\n /**\n * Disables rate limiting\n *\n * @returns The builder instance for chaining\n */\n disableRateLimit(): this {\n return this.setEnabled('rateLimit', false);\n }\n\n /**\n * Configures HTTP request logging middleware.\n *\n * @param opts - Request logging configuration options\n * @returns The builder instance for chaining\n * @default { enable: true in dev/false in prod, ignorePaths: ['/healthz', '/favicon.ico', '/metrics', '/docs', '/.well-known'], skipNotFoundRoutes: false }\n *\n * @example\n * ```typescript\n * builder.withRequestLogging({\n * enable: true,\n * ignorePaths: ['/health', '/metrics'],\n * skipNotFoundRoutes: true\n * })\n * ```\n */\n withRequestLogging(opts: Partial<NonNullable<ServerConfig['requestLogging']>>): this {\n this.mergeConfig('requestLogging', opts as NonNullable<ServerConfig['requestLogging']>);\n return this;\n }\n\n /**\n * Enables request logging with default or custom settings\n *\n * @param opts - Optional request logging configuration\n * @returns The builder instance for chaining\n */\n enableRequestLogging(opts: Omit<Partial<NonNullable<ServerConfig['requestLogging']>>, 'enable'> = {}): this {\n return this.setEnabled('requestLogging', true, opts);\n }\n\n /**\n * Disables request logging\n *\n * @returns The builder instance for chaining\n */\n disableRequestLogging(): this {\n return this.setEnabled('requestLogging', false);\n }\n\n /**\n * Configures server metrics collection and endpoints.\n *\n * @param opts - Metrics configuration options\n * @returns The builder instance for chaining\n * @default { enable: false, path: '/metrics', withGlobalPrefix: false }\n *\n * @example\n * ```typescript\n * builder.withMetrics({\n * enable: true,\n * path: '/metrics'\n * })\n * ```\n */\n withMetrics(opts: Partial<NonNullable<ServerConfig['metrics']>>): this {\n this.mergeConfig('metrics', opts as NonNullable<ServerConfig['metrics']>);\n return this;\n }\n\n /**\n * Enables Prometheus metrics collection and endpoint\n *\n * @param opts - Optional metrics configuration\n * @returns The builder instance for chaining\n */\n enableMetrics(opts: Omit<Partial<NonNullable<ServerConfig['metrics']>>, 'enable'> = {}): this {\n return this.setEnabled('metrics', true, opts);\n }\n\n /**\n * Disables Prometheus metrics\n *\n * @returns The builder instance for chaining\n */\n disableMetrics(): this {\n return this.setEnabled('metrics', false);\n }\n\n /**\n * Configures server health check endpoint.\n *\n * @param opts - Health check configuration options\n * @returns The builder instance for chaining\n * @default { path: '/healthz', detailed: true, withGlobalPrefix: false }\n *\n * @example\n * ```typescript\n * builder.withHealthCheck({\n * path: '/health',\n * detailed: true\n * })\n * ```\n */\n withHealthCheck(opts: Partial<NonNullable<ServerConfig['healthCheck']>>): this {\n this.mergeConfig('healthCheck', opts as NonNullable<ServerConfig['healthCheck']>);\n return this;\n }\n\n /**\n * Configures OpenAPI/Swagger documentation for the API.\n *\n * @param opts - OpenAPI configuration options\n * @returns The builder instance for chaining\n * @default { enable: false, mountPath: '/docs', verbose: false, withGlobalPrefix: false }\n *\n * @example\n * ```typescript\n * builder.withOpenApi({\n * enable: true,\n * path: '/api-docs',\n * filePath: './openapi.yaml'\n * })\n * ```\n */\n withOpenApi(opts: Partial<NonNullable<ServerConfig['openApi']>>): this {\n this.mergeConfig('openApi', opts as NonNullable<ServerConfig['openApi']>);\n return this;\n }\n\n /**\n * Enables OpenAPI documentation with required file path\n *\n * @param filePath - Path to OpenAPI specification file (required)\n * @param opts - Optional OpenAPI configuration\n * @returns The builder instance for chaining\n */\n enableOpenApi(\n filePath: string,\n opts: Omit<Partial<NonNullable<ServerConfig['openApi']>>, 'enable' | 'filePath'> = {}\n ): this {\n this.setEnabled('openApi', true, { filePath, ...opts });\n return this;\n }\n\n /**\n * Disables OpenAPI documentation\n *\n * @returns The builder instance for chaining\n */\n disableOpenApi(): this {\n return this.setEnabled('openApi', false);\n }\n\n /**\n * Configures the server as a microservice with versioning.\n *\n * @param opts - Microservice configuration options including app name and service version\n * @returns The builder instance for chaining\n * @default { isMicroservice: false, appName: 'express_app' }\n *\n * @example\n * ```typescript\n * builder.withMicroService({\n * appName: 'user-service',\n * serviceVersion: {\n * enable: true,\n * version: '1.2.3'\n * }\n * })\n * ```\n */\n withMicroService(opts: {\n appName: NonNullable<ServerConfig['appName']>;\n serviceVersion: Partial<NonNullable<ServerConfig['serviceVersion']>>;\n }): this {\n this.config.isMicroservice = true;\n this.config.appName = opts.appName;\n\n this.mergeConfig('serviceVersion', opts.serviceVersion as NonNullable<ServerConfig['serviceVersion']>);\n return this;\n }\n\n /**\n * Configures the trust proxy settings to determine if X-Forwarded-* headers should be trusted.\n *\n * @param opts - Trust proxy configuration options\n * @returns The builder instance for chaining\n * @default false\n *\n * @example\n * ```typescript\n * // Trust proxy headers (useful when behind a load balancer)\n * builder.withTrustProxy(true)\n * ```\n */\n withTrustProxy(opts: NonNullable<ServerConfig['trustProxy']>): this {\n this.config.trustProxy = opts;\n return this;\n }\n\n /**\n * Configures the request ID middleware for tracing requests across services.\n *\n * @param opts - Request ID configuration options\n * @returns The builder instance for chaining\n * @default { headerName: 'x-request-id', exposeHeader: true }\n *\n * @example\n * ```typescript\n * builder.withRequestId({\n * headerName: 'X-Request-Id',\n * generator: () => crypto.randomUUID()\n * })\n * ```\n */\n withRequestId(opts: Partial<NonNullable<ServerConfig['requestId']>>): this {\n this.mergeConfig('requestId', opts as NonNullable<ServerConfig['requestId']>);\n return this;\n }\n\n /**\n * Configures the response time middleware for measuring request processing times.\n *\n * @param opts - Response time configuration options\n * @returns The builder instance for chaining\n * @default { enable: false, addHeader: true, logOnComplete: false }\n *\n * @example\n * ```typescript\n * builder.withResponseTime({\n * enable: true,\n * addHeader: true,\n * logOnComplete: true\n * })\n * ```\n */\n withResponseTime(opts: Partial<NonNullable<ServerConfig['responseTime']>>): this {\n this.mergeConfig('responseTime', opts as NonNullable<ServerConfig['responseTime']>);\n return this;\n }\n\n /**\n * Enables response time tracking with default or custom settings\n *\n * @param opts - Optional response time configuration\n * @returns The builder instance for chaining\n */\n enableResponseTime(opts: Omit<Partial<NonNullable<ServerConfig['responseTime']>>, 'enable'> = {}): this {\n this.setEnabled('responseTime', true, opts);\n return this;\n }\n\n /**\n * Disables response time tracking\n *\n * @returns The builder instance for chaining\n */\n disableResponseTime(): this {\n return this.setEnabled('responseTime', false);\n }\n\n /**\n * Configures the body parser middleware options for parsing request bodies.\n *\n * @param opts - Body parser configuration options\n * @returns The builder instance for chaining\n * @default { json: { limit: '1mb' }, urlencoded: { extended: true, limit: '1mb' } }\n *\n * @example\n * ```typescript\n * builder.withBodyParser({\n * json: {\n * limit: '1mb'\n * },\n * urlencoded: {\n * extended: true,\n * limit: '1mb'\n * }\n * })\n * ```\n */\n withBodyParser(opts: NonNullable<ServerConfig['bodyParser']>): this {\n this.config.bodyParser = deepObjMerge({}, this.config.bodyParser ?? {}, opts);\n return this;\n }\n\n /**\n * Configures cookie parsing middleware.\n *\n * @param opts - Cookie parser options or boolean (true to enable with defaults, false to disable)\n * @returns The builder instance for chaining\n * @default false\n *\n * @example\n * ```typescript\n * // Enable cookie parsing with default options\n * builder.withCookies(true)\n *\n * // Enable cookie parsing with specific options\n * builder.withCookies({\n * secret: 'your-secret-key',\n * secure: true\n * })\n * ```\n */\n withCookies(opts: ServerConfig['cookieParser']): this {\n this.config.cookieParser = opts;\n return this;\n }\n\n /**\n * Adds a static folder to serve files from.\n *\n * @param folder - Static folder configuration\n * @returns The builder instance for chaining\n *\n * @example\n * ```typescript\n * builder.withStaticFolder({\n * path: '/assets',\n * directory: './public',\n * options: { maxAge: '1d' }\n * })\n * ```\n */\n withStaticFolder(folder: NonNullable<ServerConfig['staticFolders']>[number]): this {\n if (!folder.path) throw new Error('Static folder requires a path');\n const folders = [...(this.config.staticFolders ?? []), folder];\n this.config.staticFolders = Array.from(new Map(folders.map(f => [f.path, f])).values());\n return this;\n }\n\n /**\n * Sets global headers to be included in all responses.\n *\n * @param headers - Object containing header name/value pairs or functions that return values\n * @returns The builder instance for chaining\n * @default {}\n *\n * @example\n * ```typescript\n * builder.withGlobalHeaders({\n * 'X-Powered-By': 'Catbee',\n * 'Server-Time': () => new Date().toISOString()\n * })\n * ```\n */\n withGlobalHeaders(headers: NonNullable<ServerConfig['globalHeaders']>): this {\n this.mergeConfig('globalHeaders', headers);\n return this;\n }\n\n /**\n * Sets a global prefix for all routes.\n *\n * @param prefix - The prefix to prepend to all routes (e.g., '/api/v1')\n * @returns The builder instance for chaining\n * @default '/'\n *\n * @example\n * ```typescript\n * builder.withGlobalPrefix('/api/v1')\n * ```\n */\n withGlobalPrefix(prefix: string): this {\n this.config.globalPrefix = prefix;\n return this;\n }\n\n /**\n * Applies custom configuration overrides directly.\n *\n * @param overrides - Custom configuration options to merge\n * @returns The builder instance for chaining\n *\n * @example\n * ```typescript\n * builder.withCustom({\n * port: 8080,\n * customMiddleware: myMiddlewareFunction\n * })\n * ```\n */\n withCustom(overrides: Partial<ServerConfig>): this {\n this.config = deepObjMerge({}, this.config, overrides);\n return this;\n }\n\n /**\n * Configures HTTPS server options.\n *\n * @param opts - HTTPS configuration (key, cert, ca, passphrase, etc.)\n * @returns The builder instance for chaining\n *\n * @example\n * ```typescript\n * builder.withHttps({\n * key: './localhost-key.pem',\n * cert: './localhost-cert.pem'\n * })\n * ```\n */\n withHttps(opts: NonNullable<ServerConfig['https']>): this {\n this.config.https = opts;\n return this;\n }\n\n /**\n * Builds and returns the final server configuration.\n *\n * This method merges the user-specified configuration with default values,\n * ensures all sections with 'enable' flags are properly structured, and\n * produces the final configuration to be used by the server.\n *\n * @returns The complete ServerConfig object\n *\n * @example\n * ```typescript\n * const config = new ServerConfigBuilder()\n * .withPort(3000)\n * .withHost('localhost')\n * .withCors(true)\n * .build();\n * ```\n */\n build(): Readonly<ServerConfig> {\n const config = deepObjMerge({}, defaultServerConfig, this.config) as ServerConfig;\n\n // Common validation\n if (config.openApi?.enable && !config.openApi.filePath) {\n throw new Error('OpenAPI is enabled but no filePath is specified');\n }\n\n return Object.freeze({\n ...config,\n [BUILD_MARKER]: true\n });\n }\n\n private mergeConfig<K extends keyof ServerConfig>(key: K, value: Partial<NonNullable<ServerConfig[K]>>): void {\n const current =\n typeof this.config[key] === 'object' && this.config[key] !== null\n ? (this.config[key] as NonNullable<ServerConfig[K]>)\n : {};\n this.config[key] = deepObjMerge({}, current, value) as NonNullable<ServerConfig[K]>;\n }\n\n private setEnabled<K extends keyof ServerConfig>(\n key: K,\n enable: boolean,\n overrides: Partial<NonNullable<ServerConfig[K]>> = {}\n ): this {\n this.mergeConfig(key, { ...overrides, enable });\n return this;\n }\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import express, { Express, Router } from 'express';
|
|
2
2
|
import http from 'http';
|
|
3
3
|
import https from 'https';
|
|
4
|
-
import client from 'prom-client';
|
|
5
4
|
import { ServerConfig, ServerHooks } from '../types/server';
|
|
6
5
|
/**
|
|
7
6
|
* Production-ready Express server with enterprise features.
|
|
@@ -231,7 +230,7 @@ export declare class ExpressServer {
|
|
|
231
230
|
*
|
|
232
231
|
* @return {*} {client.Registry}
|
|
233
232
|
*/
|
|
234
|
-
getMetricsRegistry(): client.Registry;
|
|
233
|
+
getMetricsRegistry(): typeof import("prom-client").Registry;
|
|
235
234
|
/**
|
|
236
235
|
* Get server configuration
|
|
237
236
|
*
|
|
@@ -252,5 +251,6 @@ export declare class ExpressServer {
|
|
|
252
251
|
private destroyConnections;
|
|
253
252
|
private validateHttpsFiles;
|
|
254
253
|
private static isBuiltServerConfig;
|
|
254
|
+
private static optionalRequire;
|
|
255
255
|
}
|
|
256
256
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c) 2025 Catbee Technologies
|
|
5
|
+
* Copyright (c) 2025 Catbee Technologies. https://catbee-utils.npm.hprasath.com/license
|
|
6
6
|
*
|
|
7
7
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
8
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -22,39 +22,6 @@
|
|
|
22
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26
|
-
if (k2 === undefined) k2 = k;
|
|
27
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
28
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
29
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
30
|
-
}
|
|
31
|
-
Object.defineProperty(o, k2, desc);
|
|
32
|
-
}) : (function(o, m, k, k2) {
|
|
33
|
-
if (k2 === undefined) k2 = k;
|
|
34
|
-
o[k2] = m[k];
|
|
35
|
-
}));
|
|
36
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
37
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
38
|
-
}) : function(o, v) {
|
|
39
|
-
o["default"] = v;
|
|
40
|
-
});
|
|
41
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
42
|
-
var ownKeys = function(o) {
|
|
43
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
44
|
-
var ar = [];
|
|
45
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
46
|
-
return ar;
|
|
47
|
-
};
|
|
48
|
-
return ownKeys(o);
|
|
49
|
-
};
|
|
50
|
-
return function (mod) {
|
|
51
|
-
if (mod && mod.__esModule) return mod;
|
|
52
|
-
var result = {};
|
|
53
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
54
|
-
__setModuleDefault(result, mod);
|
|
55
|
-
return result;
|
|
56
|
-
};
|
|
57
|
-
})();
|
|
58
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
27
|
};
|
|
@@ -62,21 +29,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
62
29
|
exports.ExpressServer = void 0;
|
|
63
30
|
const express_1 = __importDefault(require("express"));
|
|
64
31
|
const https_1 = __importDefault(require("https"));
|
|
65
|
-
const cors_1 = __importDefault(require("cors"));
|
|
66
|
-
const helmet_1 = __importDefault(require("helmet"));
|
|
67
|
-
const compression_1 = __importDefault(require("compression"));
|
|
68
|
-
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
69
|
-
const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
|
|
70
32
|
const http_status_codes_1 = require("../utils/http-status-codes");
|
|
71
33
|
const response_utils_1 = require("../utils/response.utils");
|
|
72
34
|
const middleware_utils_1 = require("../utils/middleware.utils");
|
|
73
35
|
const env_utils_1 = require("../utils/env.utils");
|
|
74
36
|
const logger_utils_1 = require("../utils/logger.utils");
|
|
75
37
|
const exception_utils_1 = require("../utils/exception.utils");
|
|
76
|
-
const prom_client_1 = __importStar(require("prom-client"));
|
|
77
38
|
const exception_utils_2 = require("../utils/exception.utils");
|
|
78
39
|
const fs_1 = __importDefault(require("fs"));
|
|
79
|
-
const express_api_reference_1 = require("@scalar/express-api-reference");
|
|
80
40
|
const config_1 = require("../config");
|
|
81
41
|
const obj_utils_1 = require("../utils/obj.utils");
|
|
82
42
|
const fs_utils_1 = require("../utils/fs.utils");
|
|
@@ -117,7 +77,7 @@ class ExpressServer {
|
|
|
117
77
|
constructor(config, hooks = {}) {
|
|
118
78
|
var _a, _b, _c;
|
|
119
79
|
/** Prometheus client registry for metrics collection */
|
|
120
|
-
this.register =
|
|
80
|
+
this.register = null;
|
|
121
81
|
/** HTTP server instance (null when not running) */
|
|
122
82
|
this.server = null;
|
|
123
83
|
/** Set of active WebSocket connections */
|
|
@@ -137,40 +97,47 @@ class ExpressServer {
|
|
|
137
97
|
this.config = (0, obj_utils_1.deepObjMerge)({}, config_1.defaultServerConfig, config);
|
|
138
98
|
}
|
|
139
99
|
if (!(0, validate_utils_1.isPort)(this.config.port)) {
|
|
140
|
-
|
|
100
|
+
(0, logger_utils_1.getLogger)().error(`Port must be a valid number between 1 and 65535, got: ${this.config.port}`);
|
|
101
|
+
process.exit(1);
|
|
141
102
|
}
|
|
142
103
|
// Sanitize app name for metrics (replace invalid characters with underscore)
|
|
143
104
|
const safeAppName = (this.config.appName || 'express_app').toLowerCase().replace(/[^a-z0-9_]/g, '_');
|
|
144
105
|
if ((_a = this.config.metrics) === null || _a === void 0 ? void 0 : _a.enable) {
|
|
106
|
+
const client = ExpressServer.optionalRequire('prom-client');
|
|
107
|
+
if (!client) {
|
|
108
|
+
(0, logger_utils_1.getLogger)().error({ command: 'npm install prom-client' }, 'prom-client is required for metrics but not installed. Please add it to your dependencies');
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
this.register = new client.Registry();
|
|
145
112
|
// Initialize Prometheus metrics with sanitized names
|
|
146
|
-
this.requestCounter = new
|
|
113
|
+
this.requestCounter = new client.Counter({
|
|
147
114
|
name: `${safeAppName}_http_requests_total`,
|
|
148
115
|
help: 'Total HTTP requests',
|
|
149
116
|
labelNames: ['method', 'route', 'status'],
|
|
150
117
|
registers: [this.register]
|
|
151
118
|
});
|
|
152
|
-
this.routeTimings = new
|
|
119
|
+
this.routeTimings = new client.Histogram({
|
|
153
120
|
name: `${safeAppName}_http_request_duration_seconds`,
|
|
154
121
|
help: 'Duration of HTTP requests by route',
|
|
155
122
|
labelNames: ['method', 'route', 'status'],
|
|
156
123
|
buckets: [0.1, 0.3, 0.5, 0.7, 1, 3, 5, 7, 10],
|
|
157
124
|
registers: [this.register]
|
|
158
125
|
});
|
|
159
|
-
this.requestSizes = new
|
|
126
|
+
this.requestSizes = new client.Histogram({
|
|
160
127
|
name: `${safeAppName}_http_request_size_bytes`,
|
|
161
128
|
help: 'Size of HTTP request bodies',
|
|
162
129
|
labelNames: ['method', 'route'],
|
|
163
130
|
buckets: [100, 1000, 10000, 100000, 1000000],
|
|
164
131
|
registers: [this.register]
|
|
165
132
|
});
|
|
166
|
-
this.clientIPs = new
|
|
133
|
+
this.clientIPs = new client.Counter({
|
|
167
134
|
name: `${safeAppName}_http_client_ip_total`,
|
|
168
135
|
help: 'Client IP request counter',
|
|
169
136
|
labelNames: ['ip', 'method'],
|
|
170
137
|
registers: [this.register]
|
|
171
138
|
});
|
|
172
139
|
// Default system metrics (CPU, memory, event loop lag, etc.)
|
|
173
|
-
|
|
140
|
+
client.collectDefaultMetrics({
|
|
174
141
|
register: this.register,
|
|
175
142
|
prefix: `${safeAppName}_`
|
|
176
143
|
});
|
|
@@ -268,16 +235,26 @@ class ExpressServer {
|
|
|
268
235
|
});
|
|
269
236
|
// Security middleware should come early
|
|
270
237
|
if (this.config.helmet) {
|
|
238
|
+
const helmet = ExpressServer.optionalRequire('helmet');
|
|
239
|
+
if (!helmet) {
|
|
240
|
+
(0, logger_utils_1.getLogger)().error({ command: 'npm install helmet' }, 'helmet is required but not installed. Please add it to your dependencies');
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
271
243
|
if (typeof this.config.helmet === 'object') {
|
|
272
|
-
this.app.use((
|
|
244
|
+
this.app.use(helmet(this.config.helmet));
|
|
273
245
|
}
|
|
274
246
|
else {
|
|
275
|
-
this.app.use((
|
|
247
|
+
this.app.use(helmet());
|
|
276
248
|
}
|
|
277
249
|
}
|
|
278
250
|
// CORS middleware should be early
|
|
279
251
|
if (this.config.cors) {
|
|
280
|
-
|
|
252
|
+
const cors = ExpressServer.optionalRequire('cors');
|
|
253
|
+
if (!cors) {
|
|
254
|
+
(0, logger_utils_1.getLogger)().error({ command: 'npm install cors' }, 'cors is required but not installed. Please add it to your dependencies');
|
|
255
|
+
process.exit(1);
|
|
256
|
+
}
|
|
257
|
+
this.app.use(cors(this.config.cors === true ? {} : this.config.cors));
|
|
281
258
|
}
|
|
282
259
|
// Global headers
|
|
283
260
|
this.app.use((_req, res, next) => {
|
|
@@ -312,7 +289,12 @@ class ExpressServer {
|
|
|
312
289
|
}
|
|
313
290
|
// Rate limiting should be early to prevent unnecessary processing
|
|
314
291
|
if ((_f = this.config.rateLimit) === null || _f === void 0 ? void 0 : _f.enable) {
|
|
315
|
-
|
|
292
|
+
const rateLimit = ExpressServer.optionalRequire('express-rate-limit');
|
|
293
|
+
if (!rateLimit) {
|
|
294
|
+
(0, logger_utils_1.getLogger)().error({ command: 'npm install express-rate-limit' }, 'express-rate-limit is required but not installed. Please add it to your dependencies');
|
|
295
|
+
process.exit(1);
|
|
296
|
+
}
|
|
297
|
+
this.app.use(rateLimit({
|
|
316
298
|
windowMs: (_g = this.config.rateLimit.windowMs) !== null && _g !== void 0 ? _g : 15 * 60 * 1000,
|
|
317
299
|
max: (_h = this.config.rateLimit.max) !== null && _h !== void 0 ? _h : 100,
|
|
318
300
|
handler: (req, res) => {
|
|
@@ -356,11 +338,16 @@ class ExpressServer {
|
|
|
356
338
|
}
|
|
357
339
|
// Response compression for better performance
|
|
358
340
|
if (this.config.compression) {
|
|
341
|
+
const compression = ExpressServer.optionalRequire('compression');
|
|
342
|
+
if (!compression) {
|
|
343
|
+
(0, logger_utils_1.getLogger)().error({ command: 'npm install compression' }, 'compression is required but not installed. Please add it to your dependencies');
|
|
344
|
+
process.exit(1);
|
|
345
|
+
}
|
|
359
346
|
if (typeof this.config.compression === 'object') {
|
|
360
|
-
this.app.use((
|
|
347
|
+
this.app.use(compression(this.config.compression));
|
|
361
348
|
}
|
|
362
349
|
else {
|
|
363
|
-
this.app.use((
|
|
350
|
+
this.app.use(compression());
|
|
364
351
|
}
|
|
365
352
|
}
|
|
366
353
|
// Static file serving (do NOT normalize filesystem path; only normalize route)
|
|
@@ -388,11 +375,16 @@ class ExpressServer {
|
|
|
388
375
|
}
|
|
389
376
|
// Cookie parser middleware
|
|
390
377
|
if (this.config.cookieParser) {
|
|
378
|
+
const cookieParser = ExpressServer.optionalRequire('cookie-parser');
|
|
379
|
+
if (!cookieParser) {
|
|
380
|
+
(0, logger_utils_1.getLogger)().error({ command: 'npm install cookie-parser' }, 'cookie-parser is required but not installed. Please add it to your dependencies');
|
|
381
|
+
process.exit(1);
|
|
382
|
+
}
|
|
391
383
|
if (typeof this.config.cookieParser === 'object') {
|
|
392
|
-
this.app.use((
|
|
384
|
+
this.app.use(cookieParser(undefined, this.config.cookieParser));
|
|
393
385
|
}
|
|
394
386
|
else {
|
|
395
|
-
this.app.use((
|
|
387
|
+
this.app.use(cookieParser());
|
|
396
388
|
}
|
|
397
389
|
}
|
|
398
390
|
// OpenAPI docs via @scalar/express-api-reference
|
|
@@ -401,17 +393,24 @@ class ExpressServer {
|
|
|
401
393
|
const openApiMountPath = this.normalizePath((_o = this.config.openApi.mountPath) !== null && _o !== void 0 ? _o : '/docs', this.config.openApi.withGlobalPrefix);
|
|
402
394
|
const openApiFilePath = this.config.openApi.filePath;
|
|
403
395
|
if (!openApiFilePath) {
|
|
404
|
-
|
|
396
|
+
(0, logger_utils_1.getLogger)().error('OpenAPI file path is required');
|
|
397
|
+
process.exit(1);
|
|
405
398
|
}
|
|
406
399
|
const isOpenApiFilePathExists = await (0, fs_utils_1.fileExists)(openApiFilePath);
|
|
407
400
|
if (!isOpenApiFilePathExists) {
|
|
408
|
-
|
|
401
|
+
(0, logger_utils_1.getLogger)().error(`OpenAPI spec file not found at ${openApiFilePath}`);
|
|
402
|
+
process.exit(1);
|
|
409
403
|
}
|
|
410
404
|
if ((_p = this.config.openApi) === null || _p === void 0 ? void 0 : _p.verbose) {
|
|
411
405
|
(0, logger_utils_1.getLogger)().info(`Mounting OpenAPI docs at ${openApiMountPath}`);
|
|
412
406
|
(0, logger_utils_1.getLogger)().info(`Using OpenAPI spec file at ${openApiFilePath}`);
|
|
413
407
|
}
|
|
414
|
-
|
|
408
|
+
const apiReference = ExpressServer.optionalRequire('@scalar/express-api-reference').apiReference;
|
|
409
|
+
if (!apiReference) {
|
|
410
|
+
(0, logger_utils_1.getLogger)().error({ command: 'npm install @scalar/express-api-reference' }, '@scalar/express-api-reference is required for OpenAPI docs but not installed. Please add it to your dependencies');
|
|
411
|
+
process.exit(1);
|
|
412
|
+
}
|
|
413
|
+
this.app.use(openApiMountPath, apiReference({
|
|
415
414
|
spec: {
|
|
416
415
|
content: await fs_1.default.promises.readFile(openApiFilePath, 'utf8')
|
|
417
416
|
}
|
|
@@ -848,6 +847,10 @@ class ExpressServer {
|
|
|
848
847
|
* @return {*} {client.Registry}
|
|
849
848
|
*/
|
|
850
849
|
getMetricsRegistry() {
|
|
850
|
+
var _a;
|
|
851
|
+
if (!((_a = this.config.metrics) === null || _a === void 0 ? void 0 : _a.enable)) {
|
|
852
|
+
throw new Error('Metrics are not enabled in the server configuration');
|
|
853
|
+
}
|
|
851
854
|
return this.register;
|
|
852
855
|
}
|
|
853
856
|
/**
|
|
@@ -928,13 +931,16 @@ class ExpressServer {
|
|
|
928
931
|
}
|
|
929
932
|
async validateHttpsFiles() {
|
|
930
933
|
if (!(await (0, fs_utils_1.fileExists)(this.config.https.key))) {
|
|
931
|
-
|
|
934
|
+
(0, logger_utils_1.getLogger)().error(`HTTPS key file not found: ${this.config.https.key}`);
|
|
935
|
+
process.exit(1);
|
|
932
936
|
}
|
|
933
937
|
if (!(await (0, fs_utils_1.fileExists)(this.config.https.cert))) {
|
|
934
|
-
|
|
938
|
+
(0, logger_utils_1.getLogger)().error(`HTTPS cert file not found: ${this.config.https.cert}`);
|
|
939
|
+
process.exit(1);
|
|
935
940
|
}
|
|
936
941
|
if (this.config.https.ca && !(await (0, fs_utils_1.fileExists)(this.config.https.ca))) {
|
|
937
|
-
|
|
942
|
+
(0, logger_utils_1.getLogger)().error(`HTTPS CA file not found: ${this.config.https.ca}`);
|
|
943
|
+
process.exit(1);
|
|
938
944
|
}
|
|
939
945
|
}
|
|
940
946
|
static isBuiltServerConfig(config) {
|
|
@@ -943,6 +949,14 @@ class ExpressServer {
|
|
|
943
949
|
}
|
|
944
950
|
return false;
|
|
945
951
|
}
|
|
952
|
+
static optionalRequire(name) {
|
|
953
|
+
try {
|
|
954
|
+
return require(name);
|
|
955
|
+
}
|
|
956
|
+
catch (_a) {
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
946
960
|
}
|
|
947
961
|
exports.ExpressServer = ExpressServer;
|
|
948
962
|
//# sourceMappingURL=server.js.map
|