@morojs/moro 1.8.3 → 1.8.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/dist/core/config/config-sources.js.map +1 -1
- package/dist/core/framework.d.ts +11 -0
- package/dist/core/framework.js +107 -36
- package/dist/core/framework.js.map +1 -1
- package/dist/core/graphql/core.js.map +1 -1
- package/dist/core/grpc/types.js.map +1 -1
- package/dist/core/http/http-server.js +18 -1
- package/dist/core/http/http-server.js.map +1 -1
- package/dist/core/http/http2-server.js +13 -0
- package/dist/core/http/http2-server.js.map +1 -1
- package/dist/core/http/moro-engine-server.js +13 -0
- package/dist/core/http/moro-engine-server.js.map +1 -1
- package/dist/core/http/uws-http-server.js +16 -1
- package/dist/core/http/uws-http-server.js.map +1 -1
- package/dist/core/mail/mail-adapter.js.map +1 -1
- package/dist/core/middleware/built-in/cache/adapters/cache/memory.js +5 -1
- package/dist/core/middleware/built-in/cache/adapters/cache/memory.js.map +1 -1
- package/dist/core/middleware/built-in/cloudwatch/index.d.ts +4 -0
- package/dist/core/middleware/built-in/cloudwatch/index.js +5 -0
- package/dist/core/middleware/built-in/cloudwatch/index.js.map +1 -0
- package/dist/core/middleware/built-in/cloudwatch/middleware.d.ts +31 -0
- package/dist/core/middleware/built-in/cloudwatch/middleware.js +52 -0
- package/dist/core/middleware/built-in/cloudwatch/middleware.js.map +1 -0
- package/dist/core/middleware/built-in/error-tracker/index.d.ts +3 -1
- package/dist/core/middleware/built-in/error-tracker/index.js +3 -2
- package/dist/core/middleware/built-in/error-tracker/index.js.map +1 -1
- package/dist/core/middleware/built-in/error-tracker/middleware.d.ts +6 -3
- package/dist/core/middleware/built-in/error-tracker/middleware.js +18 -13
- package/dist/core/middleware/built-in/error-tracker/middleware.js.map +1 -1
- package/dist/core/middleware/built-in/index.d.ts +43 -7
- package/dist/core/middleware/built-in/index.js +37 -7
- package/dist/core/middleware/built-in/index.js.map +1 -1
- package/dist/core/middleware/built-in/performance-monitor/index.d.ts +3 -1
- package/dist/core/middleware/built-in/performance-monitor/index.js +3 -2
- package/dist/core/middleware/built-in/performance-monitor/index.js.map +1 -1
- package/dist/core/middleware/built-in/performance-monitor/middleware.d.ts +3 -3
- package/dist/core/middleware/built-in/performance-monitor/middleware.js +19 -17
- package/dist/core/middleware/built-in/performance-monitor/middleware.js.map +1 -1
- package/dist/core/middleware/built-in/prometheus/core.d.ts +27 -0
- package/dist/core/middleware/built-in/prometheus/core.js +0 -0
- package/dist/core/middleware/built-in/prometheus/core.js.map +1 -0
- package/dist/core/middleware/built-in/prometheus/index.d.ts +5 -0
- package/dist/core/middleware/built-in/prometheus/index.js +6 -0
- package/dist/core/middleware/built-in/prometheus/index.js.map +1 -0
- package/dist/core/middleware/built-in/prometheus/middleware.d.ts +15 -0
- package/dist/core/middleware/built-in/prometheus/middleware.js +30 -0
- package/dist/core/middleware/built-in/prometheus/middleware.js.map +1 -0
- package/dist/core/middleware/built-in/request-logger/index.d.ts +3 -1
- package/dist/core/middleware/built-in/request-logger/index.js +3 -2
- package/dist/core/middleware/built-in/request-logger/index.js.map +1 -1
- package/dist/core/middleware/built-in/request-logger/middleware.d.ts +4 -4
- package/dist/core/middleware/built-in/request-logger/middleware.js +14 -12
- package/dist/core/middleware/built-in/request-logger/middleware.js.map +1 -1
- package/dist/core/middleware/index.d.ts +3 -1
- package/dist/core/middleware/index.js +6 -1
- package/dist/core/middleware/index.js.map +1 -1
- package/dist/core/pooling/index.d.ts +3 -0
- package/dist/core/pooling/index.js +5 -0
- package/dist/core/pooling/index.js.map +1 -0
- package/dist/core/pooling/lru-cache.d.ts +32 -0
- package/dist/core/pooling/lru-cache.js +74 -0
- package/dist/core/pooling/lru-cache.js.map +1 -0
- package/dist/core/pooling/object-pool-manager.d.ts +3 -1
- package/dist/core/pooling/object-pool-manager.js +37 -140
- package/dist/core/pooling/object-pool-manager.js.map +1 -1
- package/dist/core/pooling/object-pool.d.ts +42 -0
- package/dist/core/pooling/object-pool.js +78 -0
- package/dist/core/pooling/object-pool.js.map +1 -0
- package/dist/core/routing/create-router.js.map +1 -1
- package/dist/core/routing/path-matcher.js +1 -43
- package/dist/core/routing/path-matcher.js.map +1 -1
- package/dist/core/routing/unified-router.d.ts +2 -0
- package/dist/core/routing/unified-router.js +15 -0
- package/dist/core/routing/unified-router.js.map +1 -1
- package/dist/core/utilities/hooks.d.ts +5 -5
- package/dist/core/utilities/hooks.js +9 -6
- package/dist/core/utilities/hooks.js.map +1 -1
- package/dist/core/utilities/index.d.ts +0 -1
- package/dist/core/utilities/index.js +0 -2
- package/dist/core/utilities/index.js.map +1 -1
- package/dist/core/workers/facade.d.ts +20 -4
- package/dist/core/workers/facade.js +15 -7
- package/dist/core/workers/facade.js.map +1 -1
- package/dist/core/workers/worker-manager.d.ts +12 -0
- package/dist/core/workers/worker-manager.js +27 -0
- package/dist/core/workers/worker-manager.js.map +1 -1
- package/dist/core/workers/worker.d.ts +17 -1
- package/dist/core/workers/worker.js +28 -26
- package/dist/core/workers/worker.js.map +1 -1
- package/dist/index.d.ts +39 -2
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/moro.d.ts +1 -0
- package/dist/moro.js +82 -15
- package/dist/moro.js.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/types/core.d.ts +1 -0
- package/dist/types/core.js.map +1 -1
- package/dist/types/hooks.d.ts +2 -0
- package/dist/types/hooks.js.map +1 -1
- package/dist/types/module.js.map +1 -1
- package/package.json +3 -3
|
@@ -247,6 +247,13 @@ export class MoroHttp2Server {
|
|
|
247
247
|
request: httpReq,
|
|
248
248
|
response: httpRes,
|
|
249
249
|
});
|
|
250
|
+
// Post-response hooks. The HTTP/2 response object is a plain object
|
|
251
|
+
// (no event emitter), so listen on the underlying stream instead.
|
|
252
|
+
if (this.hookManager.hasHooks === undefined || this.hookManager.hasHooks('response')) {
|
|
253
|
+
stream.once('close', () => {
|
|
254
|
+
void Promise.resolve(this.hookManager.execute('response', { request: httpReq, response: httpRes })).catch((error) => this.logger?.error?.(`Response hook error: ${error?.message || error}`, 'Hooks'));
|
|
255
|
+
});
|
|
256
|
+
}
|
|
250
257
|
}
|
|
251
258
|
// Execute global middleware
|
|
252
259
|
if (this.globalMiddleware.length > 0) {
|
|
@@ -296,6 +303,12 @@ export class MoroHttp2Server {
|
|
|
296
303
|
requestId: httpReq.requestId,
|
|
297
304
|
path: httpReq.path,
|
|
298
305
|
});
|
|
306
|
+
// Error hooks are observational: fire-and-forget so a slow or throwing
|
|
307
|
+
// observer can never delay or alter the error response.
|
|
308
|
+
if (this.hookManager &&
|
|
309
|
+
(this.hookManager.hasHooks === undefined || this.hookManager.hasHooks('error'))) {
|
|
310
|
+
void Promise.resolve(this.hookManager.execute('error', { request: httpReq, response: httpRes, error })).catch((hookError) => this.logger?.error?.(`Error hook error: ${hookError?.message || hookError}`, 'Hooks'));
|
|
311
|
+
}
|
|
299
312
|
if (!httpRes.headersSent) {
|
|
300
313
|
httpRes.status(500).json({
|
|
301
314
|
success: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http2-server.js","sourceRoot":"","sources":["../../../src/core/http/http2-server.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EACL,kBAAkB,IAAI,uBAAuB,EAC7C,YAAY,IAAI,iBAAiB,GAMlC,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EACL,cAAc,IAAI,oBAAoB,GAEvC,MAAM,6BAA6B,CAAC;AAGrC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,M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AAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mBAAmB;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO;YACL,mBAAmB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;YACjD,mBAAmB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;YACjD,oBAAoB,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ;YACnD,WAAW,EAAE,SAAS;SACvB,CAAC;IACJ,CAAC","sourcesContent":["// HTTP/2 Server Implementation for Moro Framework\nimport {\n createSecureServer as createHttp2SecureServer,\n createServer as createHttp2Server,\n Http2Server,\n Http2SecureServer,\n ServerHttp2Stream,\n IncomingHttpHeaders,\n OutgoingHttpHeaders,\n} from 'http2';\nimport * as zlib from 'zlib';\nimport { promisify } from 'util';\nimport { createFrameworkLogger } from '../logger/index.js';\nimport {\n HttpRequest,\n HttpResponse,\n Middleware,\n HttpHandler,\n RouteEntry,\n} from '../../types/http.js';\nimport { PathMatcher } from '../routing/path-matcher.js';\nimport { ObjectPoolManager } from '../pooling/object-pool-manager.js';\nimport {\n parseMultipart as parseMultipartBuffer,\n type MultipartLimits,\n} from './utils/multipart-parser.js';\nimport type { HttpRuntimeLimits } from './utils/size.js';\n\nconst gzip = promisify(zlib.gzip);\nconst deflate = promisify(zlib.deflate);\n\nexport interface Http2ServerOptions {\n key?: string | Buffer;\n cert?: string | Buffer;\n ca?: string | Buffer | Array<string | Buffer>;\n allowHTTP1?: boolean;\n maxSessionMemory?: number;\n maxBodySize?: number; // Maximum body size for JSON/form data\n maxUploadSize?: number; // Maximum size for file uploads\n /** Flattened runtime limits (timeouts, maxConnections, multipart, ...). */\n limits?: HttpRuntimeLimits;\n settings?: {\n headerTableSize?: number;\n enablePush?: boolean;\n initialWindowSize?: number;\n maxFrameSize?: number;\n maxConcurrentStreams?: number;\n maxHeaderListSize?: number;\n maxHeaderSize?: number;\n enableConnectProtocol?: boolean;\n };\n}\n\nexport class MoroHttp2Server {\n private server: Http2Server | Http2SecureServer;\n private routes: RouteEntry[] = [];\n private globalMiddleware: Middleware[] = [];\n private compressionEnabled = true;\n private compressionThreshold = 1024;\n private requestTrackingEnabled = true;\n private multipartLimits?: MultipartLimits;\n private _limits?: HttpRuntimeLimits;\n private logger = createFrameworkLogger('Http2Server');\n private hookManager: any;\n private requestCounter = 0;\n private isSecure: boolean;\n\n // Body size limits - defaults overridden by config in constructor\n private maxBodySize: number = 10 * 1024 * 1024; // Default 10MB (overridden by server.bodySizeLimit config)\n private maxUploadSize: number = 100 * 1024 * 1024; // Default 100MB for file uploads\n\n // Use shared object pool manager\n private poolManager = ObjectPoolManager.getInstance();\n\n // Interned method strings for fast comparison\n private static readonly METHOD_POST = 'POST';\n private static readonly METHOD_PUT = 'PUT';\n private static readonly METHOD_PATCH = 'PATCH';\n private static readonly METHOD_GET = 'GET';\n private static readonly METHOD_DELETE = 'DELETE';\n private static readonly METHOD_HEAD = 'HEAD';\n private static readonly METHOD_OPTIONS = 'OPTIONS';\n\n // Pre-compiled response templates\n private static readonly RESPONSE_TEMPLATES = {\n notFound: Buffer.from('{\"success\":false,\"error\":\"Not found\"}'),\n unauthorized: Buffer.from('{\"success\":false,\"error\":\"Unauthorized\"}'),\n forbidden: Buffer.from('{\"success\":false,\"error\":\"Forbidden\"}'),\n internalError: Buffer.from('{\"success\":false,\"error\":\"Internal server error\"}'),\n methodNotAllowed: Buffer.from('{\"success\":false,\"error\":\"Method not allowed\"}'),\n rateLimited: Buffer.from('{\"success\":false,\"error\":\"Rate limit exceeded\"}'),\n };\n\n // Route optimization structures\n private routeCache = new Map<string, RouteEntry | null>();\n private staticRoutes = new Map<string, RouteEntry>();\n private dynamicRoutes: RouteEntry[] = [];\n private routesBySegmentCount = new Map<number, RouteEntry[]>();\n private pathNormalizationCache = new Map<string, string>();\n\n constructor(options: Http2ServerOptions = {}) {\n this.isSecure = !!(options.key && options.cert);\n\n // Configure body size limits from options\n if (options.maxBodySize) {\n this.maxBodySize = options.maxBodySize;\n }\n if (options.maxUploadSize) {\n this.maxUploadSize = options.maxUploadSize;\n }\n if (options.limits?.multipart) this.multipartLimits = options.limits.multipart;\n if (options.limits) this._limits = options.limits;\n\n const serverOptions: any = {\n allowHTTP1: options.allowHTTP1 !== false,\n ...(options.maxSessionMemory && { maxSessionMemory: options.maxSessionMemory }),\n };\n\n // Add SSL options if secure\n if (this.isSecure) {\n serverOptions.key = options.key;\n serverOptions.cert = options.cert;\n if (options.ca) {\n serverOptions.ca = options.ca;\n }\n }\n\n // Add HTTP/2 settings\n if (options.settings) {\n serverOptions.settings = {\n headerTableSize: options.settings.headerTableSize,\n enablePush: options.settings.enablePush !== false,\n initialWindowSize: options.settings.initialWindowSize || 65535,\n maxFrameSize: options.settings.maxFrameSize || 16384,\n maxConcurrentStreams: options.settings.maxConcurrentStreams || 100,\n maxHeaderListSize: options.settings.maxHeaderListSize,\n maxHeaderSize: options.settings.maxHeaderSize,\n enableConnectProtocol: options.settings.enableConnectProtocol,\n };\n } else {\n serverOptions.settings = {\n enablePush: true,\n initialWindowSize: 65535,\n maxFrameSize: 16384,\n maxConcurrentStreams: 100,\n };\n }\n\n // Create server\n if (this.isSecure) {\n this.server = createHttp2SecureServer(serverOptions);\n this.logger.info('HTTP/2 secure server created', 'ServerInit');\n } else {\n this.server = createHttp2Server(serverOptions);\n this.logger.info('HTTP/2 server created', 'ServerInit');\n }\n\n // Configure server settings. Socket idle timeout defaults to 30s (its\n // historical hardcode) unless timeouts.idle is set (0 disables).\n this.server.setTimeout(options.limits?.timeouts?.idle ?? 30000);\n if (options.limits?.maxConnections && options.limits.maxConnections > 0) {\n (this.server as any).maxConnections = options.limits.maxConnections;\n }\n\n // Handle streams (HTTP/2 requests). Wrap so the async handler's promise is\n // always caught - a rejection escaping here becomes an unhandled rejection\n // that can crash the process.\n this.server.on('stream', (stream: ServerHttp2Stream, headers: IncomingHttpHeaders) => {\n void this.handleStream(stream, headers).catch(error => {\n this.logger.error('Unhandled HTTP/2 stream error', 'StreamError', {\n error: error instanceof Error ? error.message : String(error),\n });\n });\n });\n\n // Handle session events\n this.server.on('session', session => {\n this.logger.debug('HTTP/2 session created', 'Session');\n\n session.on('error', err => {\n this.logger.error('HTTP/2 session error', 'Session', { error: err.message });\n });\n });\n\n // Handle server errors\n this.server.on('error', err => {\n this.logger.error('HTTP/2 server error', 'ServerError', { error: err.message });\n });\n }\n\n // Configure server for maximum performance\n configurePerformance(\n config: { compression?: { enabled: boolean; threshold?: number }; minimal?: boolean } = {}\n ) {\n if (config.compression !== undefined) {\n this.compressionEnabled = config.compression.enabled;\n if (config.compression.threshold !== undefined) {\n this.compressionThreshold = config.compression.threshold;\n }\n }\n\n if (config.minimal) {\n this.compressionEnabled = false;\n this.compressionThreshold = Infinity;\n }\n }\n\n // Configure request tracking\n setRequestTracking(enabled: boolean): void {\n this.requestTrackingEnabled = enabled;\n }\n\n // Middleware management\n use(middleware: Middleware): void {\n // Defensive check: Don't add MiddlewareInterface objects to globalMiddleware\n // MiddlewareInterface objects should only be handled by MiddlewareManager\n if (\n middleware &&\n typeof middleware === 'object' &&\n (middleware as any).install &&\n (middleware as any).metadata\n ) {\n this.logger?.warn?.(\n `Attempted to add MiddlewareInterface \"${(middleware as any).metadata?.name}\" to HTTP server globalMiddleware. ` +\n `This should be handled by MiddlewareManager instead. Skipping.`,\n 'Middleware'\n );\n return;\n }\n\n this.globalMiddleware.push(middleware);\n }\n\n // Set hooks manager\n setHookManager(hookManager: any): void {\n this.hookManager = hookManager;\n }\n\n // Routing methods\n get(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('GET', path, handlers);\n }\n\n post(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('POST', path, handlers);\n }\n\n put(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('PUT', path, handlers);\n }\n\n delete(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('DELETE', path, handlers);\n }\n\n patch(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('PATCH', path, handlers);\n }\n\n private addRoute(method: string, path: string, handlers: (Middleware | HttpHandler)[]): void {\n const { pattern, paramNames } = this.pathToRegex(path);\n const handler = handlers.pop() as HttpHandler;\n const middleware = handlers as Middleware[];\n\n const route = {\n method,\n path,\n pattern,\n paramNames,\n handler,\n middleware,\n };\n\n this.routes.push(route);\n\n // Organize routes for optimal lookup\n if (paramNames.length === 0) {\n const staticKey = `${method}:${path}`;\n this.staticRoutes.set(staticKey, route);\n } else {\n this.dynamicRoutes.push(route);\n const segmentCount = PathMatcher.countSegments(path);\n if (!this.routesBySegmentCount.has(segmentCount)) {\n this.routesBySegmentCount.set(segmentCount, []);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.routesBySegmentCount.get(segmentCount)!.push(route);\n }\n }\n\n private pathToRegex(path: string): { pattern: RegExp; paramNames: string[] } {\n const compiled = PathMatcher.compile(path);\n return {\n pattern: compiled.pattern || new RegExp(`^${path.replace(/\\//g, '\\\\/')}$`),\n paramNames: compiled.paramNames,\n };\n }\n\n private async handleStream(\n stream: ServerHttp2Stream,\n headers: IncomingHttpHeaders\n ): Promise<void> {\n this.requestCounter++;\n\n const httpReq = this.createRequestFromStream(stream, headers);\n const httpRes = this.createResponseFromStream(stream, httpReq);\n\n try {\n // Parse URL and query\n const url = (headers[':path'] as string) || '/';\n const queryIndex = url.indexOf('?');\n\n if (queryIndex === -1) {\n httpReq.path = url;\n httpReq.query = {};\n } else {\n httpReq.path = url.substring(0, queryIndex);\n httpReq.query = this.parseQueryString(url.substring(queryIndex + 1));\n }\n\n // Parse body for POST/PUT/PATCH\n const method = httpReq.method;\n if (\n method === MoroHttp2Server.METHOD_POST ||\n method === MoroHttp2Server.METHOD_PUT ||\n method === MoroHttp2Server.METHOD_PATCH\n ) {\n httpReq.body = await this.parseBody(stream, headers);\n }\n\n // Execute hooks\n if (this.hookManager) {\n await this.hookManager.execute('request', {\n request: httpReq,\n response: httpRes,\n });\n }\n\n // Execute global middleware\n if (this.globalMiddleware.length > 0) {\n await this.executeMiddleware(this.globalMiddleware, httpReq, httpRes);\n }\n\n // If middleware handled the request, don't continue\n if (httpRes.headersSent) {\n return;\n }\n\n // Find matching route (path is always set after URL parsing)\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const route = this.findRoute(method || MoroHttp2Server.METHOD_GET, httpReq.path!);\n if (!route) {\n httpRes.statusCode = 404;\n httpRes.setHeader('Content-Type', 'application/json; charset=utf-8');\n httpRes.setHeader('Content-Length', MoroHttp2Server.RESPONSE_TEMPLATES.notFound.length);\n httpRes.end(MoroHttp2Server.RESPONSE_TEMPLATES.notFound);\n return;\n }\n\n // Extract path parameters\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const matches = httpReq.path!.match(route.pattern);\n if (matches) {\n httpReq.params = this.poolManager.acquireParams();\n const paramNames = route.paramNames;\n for (let i = 0; i < paramNames.length; i++) {\n const paramName = paramNames[i];\n const value = matches[i + 1];\n if (paramName !== undefined && value !== undefined) {\n httpReq.params[paramName] = value;\n }\n }\n }\n\n // Execute route middleware\n if (route.middleware.length > 0) {\n await this.executeMiddleware(route.middleware, httpReq, httpRes);\n }\n\n // Execute handler\n const handlerResult = route.handler(httpReq, httpRes);\n if (handlerResult && typeof handlerResult.then === 'function') {\n await handlerResult;\n }\n } catch (error) {\n this.logger.error('HTTP/2 stream error', 'StreamError', {\n error: error instanceof Error ? error.message : String(error),\n requestId: httpReq.requestId,\n path: httpReq.path,\n });\n\n if (!httpRes.headersSent) {\n httpRes.status(500).json({\n success: false,\n error: 'Internal server error',\n requestId: httpReq.requestId,\n });\n }\n } finally {\n // Release pooled objects\n if (httpReq.params && Object.keys(httpReq.params).length === 0) {\n this.poolManager.releaseParams(httpReq.params);\n }\n if (httpReq.query && Object.keys(httpReq.query).length === 0) {\n this.poolManager.releaseQuery(httpReq.query);\n }\n }\n }\n\n private createRequestFromStream(\n stream: ServerHttp2Stream,\n headers: IncomingHttpHeaders\n ): HttpRequest {\n // Extract method from pseudo-header\n const methodRaw = ((headers[':method'] as string) || 'GET').toUpperCase();\n\n // Intern method string for fast comparison\n let method: string;\n switch (methodRaw) {\n case 'POST':\n method = MoroHttp2Server.METHOD_POST;\n break;\n case 'PUT':\n method = MoroHttp2Server.METHOD_PUT;\n break;\n case 'PATCH':\n method = MoroHttp2Server.METHOD_PATCH;\n break;\n case 'GET':\n method = MoroHttp2Server.METHOD_GET;\n break;\n case 'DELETE':\n method = MoroHttp2Server.METHOD_DELETE;\n break;\n case 'HEAD':\n method = MoroHttp2Server.METHOD_HEAD;\n break;\n case 'OPTIONS':\n method = MoroHttp2Server.METHOD_OPTIONS;\n break;\n default:\n method = methodRaw;\n }\n\n // Convert HTTP/2 headers to standard headers (remove pseudo-headers)\n const standardHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (!key.startsWith(':')) {\n standardHeaders[key] = Array.isArray(value) ? value.join(', ') : (value as string);\n }\n }\n\n // Parse cookies\n const cookieHeader = standardHeaders['cookie'];\n const cookies: Record<string, string> = {};\n if (cookieHeader) {\n const cookieParts = cookieHeader.split(';');\n for (const cookie of cookieParts) {\n const equalIndex = cookie.indexOf('=');\n if (equalIndex > 0) {\n const name = cookie.substring(0, equalIndex).trim();\n const value = cookie.substring(equalIndex + 1);\n if (name && value) {\n try {\n cookies[name] = decodeURIComponent(value);\n } catch {\n // Malformed percent-encoding: keep the raw value rather than\n // throwing a URIError. createRequestFromStream runs before\n // handleStream's try block, so an escape here would surface as\n // an unhandled rejection and crash the process.\n cookies[name] = value;\n }\n }\n }\n }\n }\n\n const httpReq: HttpRequest = {\n method,\n path: '',\n url: (headers[':path'] as string) || '/',\n query: {},\n params: {},\n headers: standardHeaders,\n body: null,\n cookies,\n ip: (stream.session?.socket as any)?.remoteAddress || '',\n requestId: this.requestTrackingEnabled ? this.poolManager.generateRequestId() : '',\n httpVersion: '2.0',\n } as HttpRequest;\n\n // Store stream reference for push capability\n (httpReq as any)._http2Stream = stream;\n (httpReq as any)._http2Headers = headers;\n\n return httpReq;\n }\n\n private createResponseFromStream(stream: ServerHttp2Stream, req: HttpRequest): HttpResponse {\n const httpRes: any = {\n statusCode: 200,\n headersSent: false,\n _headers: {} as OutgoingHttpHeaders,\n _stream: stream,\n _req: req,\n _logger: this.logger,\n _poolManager: this.poolManager,\n _compressionEnabled: this.compressionEnabled,\n _compressionThreshold: this.compressionThreshold,\n };\n\n // Status method\n httpRes.status = (code: number) => {\n httpRes.statusCode = code;\n return httpRes;\n };\n\n // Set header\n httpRes.setHeader = (name: string, value: string | string[]) => {\n httpRes._headers[name.toLowerCase()] = value;\n return httpRes;\n };\n\n // Get header\n httpRes.getHeader = (name: string) => {\n return httpRes._headers[name.toLowerCase()];\n };\n\n // Remove header\n httpRes.removeHeader = (name: string) => {\n delete httpRes._headers[name.toLowerCase()];\n return httpRes;\n };\n\n // Has header\n httpRes.hasHeader = (name: string): boolean => {\n return httpRes._headers[name.toLowerCase()] !== undefined;\n };\n\n // Get headers\n httpRes.getHeaders = () => {\n return { ...httpRes._headers };\n };\n\n // JSON response\n httpRes.json = async (data: any) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n const jsonString = JSON.stringify(data);\n const finalBuffer = Buffer.from(jsonString, 'utf8');\n\n httpRes._headers['content-type'] = 'application/json; charset=utf-8';\n\n // Compression\n if (httpRes._compressionEnabled && finalBuffer.length > httpRes._compressionThreshold) {\n const acceptEncoding = req.headers['accept-encoding'];\n\n if (acceptEncoding && acceptEncoding.includes('gzip')) {\n const compressed = await gzip(finalBuffer);\n httpRes._headers['content-encoding'] = 'gzip';\n httpRes._headers['content-length'] = compressed.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(compressed);\n httpRes.headersSent = true;\n return;\n } else if (acceptEncoding && acceptEncoding.includes('deflate')) {\n const compressed = await deflate(finalBuffer);\n httpRes._headers['content-encoding'] = 'deflate';\n httpRes._headers['content-length'] = compressed.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(compressed);\n httpRes.headersSent = true;\n return;\n }\n }\n\n httpRes._headers['content-length'] = finalBuffer.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(finalBuffer);\n httpRes.headersSent = true;\n };\n\n // Send response\n httpRes.send = (data: string | Buffer) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n if (!httpRes._headers['content-type']) {\n if (typeof data === 'string') {\n try {\n JSON.parse(data);\n httpRes._headers['content-type'] = 'application/json; charset=utf-8';\n } catch {\n httpRes._headers['content-type'] = 'text/plain; charset=utf-8';\n }\n } else {\n httpRes._headers['content-type'] = 'application/octet-stream';\n }\n }\n\n const buffer = typeof data === 'string' ? Buffer.from(data) : data;\n httpRes._headers['content-length'] = buffer.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(buffer);\n httpRes.headersSent = true;\n };\n\n // End response\n httpRes.end = (data?: any) => {\n if (httpRes.headersSent || stream.destroyed) return httpRes;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(data || '');\n httpRes.headersSent = true;\n return httpRes;\n };\n\n // Standardized response helpers\n httpRes.success = <T = any>(data: T, message?: string) => {\n const response: any = {\n success: true,\n data,\n };\n if (message !== undefined) {\n response.message = message;\n }\n httpRes.json(response);\n };\n\n httpRes.error = (error: string, code?: string, message?: string) => {\n const response: any = {\n success: false,\n error,\n };\n if (code !== undefined) {\n response.code = code;\n }\n if (message !== undefined) {\n response.message = message;\n }\n httpRes.json(response);\n };\n\n // Common HTTP error helpers (automatically set status code)\n httpRes.unauthorized = (message: string = 'Authentication required') => {\n httpRes.statusCode = 401;\n httpRes.json({\n success: false,\n error: 'Unauthorized',\n code: 'UNAUTHORIZED',\n message,\n });\n };\n\n httpRes.forbidden = (message: string = 'Insufficient permissions') => {\n httpRes.statusCode = 403;\n httpRes.json({\n success: false,\n error: 'Forbidden',\n code: 'FORBIDDEN',\n message,\n });\n };\n\n httpRes.notFound = (resource: string = 'Resource') => {\n httpRes.statusCode = 404;\n httpRes.json({\n success: false,\n error: 'Not Found',\n code: 'NOT_FOUND',\n message: `${resource} not found`,\n });\n };\n\n httpRes.badRequest = (message: string = 'Invalid request') => {\n httpRes.statusCode = 400;\n httpRes.json({\n success: false,\n error: 'Bad Request',\n code: 'BAD_REQUEST',\n message,\n });\n };\n\n httpRes.conflict = (message: string) => {\n httpRes.statusCode = 409;\n httpRes.json({\n success: false,\n error: 'Conflict',\n code: 'CONFLICT',\n message,\n });\n };\n\n httpRes.internalError = (message: string = 'Internal server error') => {\n httpRes.statusCode = 500;\n httpRes.json({\n success: false,\n error: 'Internal Server Error',\n code: 'INTERNAL_ERROR',\n message,\n });\n };\n\n httpRes.validationError = (\n errors: Array<{ field: string; message: string; code?: string }>\n ) => {\n httpRes.statusCode = 422;\n httpRes.json({\n success: false,\n error: 'Validation Failed',\n code: 'VALIDATION_ERROR',\n errors,\n });\n };\n\n httpRes.rateLimited = (retryAfter?: number) => {\n httpRes.statusCode = 429;\n if (retryAfter) {\n httpRes.setHeader('Retry-After', retryAfter.toString());\n }\n httpRes.json({\n success: false,\n error: 'Rate Limit Exceeded',\n code: 'RATE_LIMITED',\n message: retryAfter\n ? `Too many requests. Retry after ${retryAfter} seconds.`\n : 'Too many requests',\n retryAfter,\n });\n };\n\n // Common success patterns\n httpRes.created = <T = any>(data: T, location?: string) => {\n httpRes.statusCode = 201;\n if (location) {\n httpRes.setHeader('Location', location);\n }\n httpRes.json({\n success: true,\n data,\n });\n };\n\n httpRes.noContent = () => {\n httpRes.statusCode = 204;\n httpRes.end();\n };\n\n httpRes.paginated = <T = any>(\n data: T[],\n pagination: { page: number; limit: number; total: number }\n ) => {\n const totalPages = Math.ceil(pagination.total / pagination.limit);\n httpRes.json({\n success: true,\n data,\n pagination: {\n page: pagination.page,\n limit: pagination.limit,\n total: pagination.total,\n totalPages,\n hasNext: pagination.page < totalPages,\n hasPrev: pagination.page > 1,\n },\n });\n };\n\n // Cookie handling\n httpRes.cookie = (name: string, value: string, options: any = {}) => {\n if (httpRes.headersSent) {\n const isCritical = options.critical || name.includes('session') || name.includes('auth');\n const message = `Cookie '${name}' could not be set - headers already sent`;\n\n if (isCritical || options.throwOnLateSet) {\n throw new Error(`${message}. This may cause authentication or security issues.`);\n } else {\n httpRes._logger.warn(message, 'CookieWarning', { cookieName: name });\n }\n return httpRes;\n }\n\n const cookieValue = encodeURIComponent(value);\n let cookieString = `${name}=${cookieValue}`;\n\n if (options.maxAge) cookieString += `; Max-Age=${options.maxAge}`;\n if (options.expires) cookieString += `; Expires=${options.expires.toUTCString()}`;\n if (options.httpOnly) cookieString += '; HttpOnly';\n if (options.secure) cookieString += '; Secure';\n if (options.sameSite) cookieString += `; SameSite=${options.sameSite}`;\n if (options.domain) cookieString += `; Domain=${options.domain}`;\n if (options.path) cookieString += `; Path=${options.path}`;\n\n const existingCookies = httpRes._headers['set-cookie'] || [];\n const cookies = Array.isArray(existingCookies)\n ? existingCookies\n : [existingCookies as string];\n cookies.push(cookieString);\n httpRes._headers['set-cookie'] = cookies;\n\n return httpRes;\n };\n\n // Clear cookie\n httpRes.clearCookie = (name: string, options: any = {}) => {\n return httpRes.cookie(name, '', {\n expires: new Date(0),\n maxAge: 0,\n ...options,\n });\n };\n\n // Redirect\n httpRes.redirect = (url: string, status: number = 302) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n httpRes.statusCode = status;\n httpRes._headers['location'] = url;\n\n stream.respond({\n ':status': status,\n ...httpRes._headers,\n });\n stream.end();\n httpRes.headersSent = true;\n };\n\n // HTTP/2 Server Push\n httpRes.push = (\n path: string,\n options: { headers?: OutgoingHttpHeaders; priority?: number } = {}\n ) => {\n if (httpRes.headersSent || stream.destroyed || !stream.pushAllowed) {\n return null;\n }\n\n try {\n const pushHeaders: any = {\n ':path': path,\n ':method': 'GET',\n ...options.headers,\n };\n\n const pushStream = stream.pushStream(pushHeaders, err => {\n if (err) {\n httpRes._logger.debug('Server push failed', 'ServerPush', {\n path,\n error: err.message,\n });\n }\n });\n\n // Set stream priority if specified\n if (options.priority !== undefined && pushStream) {\n try {\n // Priority weight: 1-256 (default 16)\n // Higher values = higher priority\n const weight = Math.max(1, Math.min(256, options.priority));\n (pushStream as any).priority({\n parent: 0,\n weight,\n exclusive: false,\n });\n } catch (error) {\n httpRes._logger.debug('Failed to set stream priority', 'StreamPriority', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return pushStream;\n } catch (error) {\n httpRes._logger.debug('Server push error', 'ServerPush', {\n path,\n error: error instanceof Error ? error.message : String(error),\n });\n return null;\n }\n };\n\n // Set stream priority for current response\n httpRes.setPriority = (\n options: { parent?: number; weight?: number; exclusive?: boolean } = {}\n ) => {\n if (httpRes.headersSent || stream.destroyed) {\n return httpRes;\n }\n\n try {\n stream.priority({\n parent: options.parent || 0,\n weight: options.weight ? Math.max(1, Math.min(256, options.weight)) : 16,\n exclusive: options.exclusive || false,\n });\n } catch (error) {\n httpRes._logger.debug('Failed to set stream priority', 'StreamPriority', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n\n return httpRes;\n };\n\n // Set bulk headers\n httpRes.setBulkHeaders = (headers: Record<string, string | number>) => {\n if (httpRes.headersSent) {\n httpRes._logger.warn('Cannot set headers - headers already sent', 'HeaderWarning');\n return httpRes;\n }\n\n for (const key in headers) {\n httpRes._headers[key.toLowerCase()] = String(headers[key]);\n }\n return httpRes;\n };\n\n // Response state\n httpRes.canSetHeaders = (): boolean => {\n return !httpRes.headersSent;\n };\n\n httpRes.getResponseState = () => {\n return {\n headersSent: httpRes.headersSent,\n statusCode: httpRes.statusCode,\n headers: httpRes.getHeaders(),\n finished: stream.destroyed,\n writable: !stream.destroyed,\n };\n };\n\n return httpRes as HttpResponse;\n }\n\n private async parseBody(stream: ServerHttp2Stream, headers: IncomingHttpHeaders): Promise<any> {\n const contentType = (headers['content-type'] as string) || '';\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const contentLength = parseInt((headers['content-length'] as string) || '0');\n\n // Use different limits based on content type\n const isMultipart = contentType.includes('multipart/form-data');\n const maxSize = isMultipart\n ? this.maxUploadSize // Configurable file upload limit (default 100MB)\n : this.maxBodySize; // Configurable body size limit (default 10MB, from server.bodySizeLimit config)\n\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let totalLength = 0;\n\n stream.on('data', (chunk: Buffer) => {\n totalLength += chunk.length;\n if (totalLength > maxSize) {\n const errorMessage = isMultipart\n ? `File upload too large. Maximum ${Math.floor(maxSize / (1024 * 1024))}MB allowed.`\n : 'Request body too large';\n reject(new Error(errorMessage));\n return;\n }\n chunks.push(chunk);\n });\n\n stream.on('end', () => {\n try {\n const body = Buffer.concat(chunks);\n\n if (contentType.includes('application/json')) {\n resolve(JSON.parse(body.toString()));\n } else if (contentType.includes('application/x-www-form-urlencoded')) {\n resolve(this.parseUrlEncoded(body.toString()));\n } else if (contentType.includes('multipart/form-data')) {\n resolve(parseMultipartBuffer(body, contentType, this.multipartLimits));\n } else {\n resolve(body.toString());\n }\n } catch (error) {\n reject(error);\n }\n });\n\n stream.on('error', reject);\n });\n }\n\n private parseUrlEncoded(body: string): Record<string, string> {\n const params = new URLSearchParams(body);\n const result: Record<string, string> = {};\n for (const [key, value] of params) {\n result[key] = value;\n }\n return result;\n }\n\n private parseQueryString(queryString: string): Record<string, string> {\n if (!queryString) return {};\n\n const result = this.poolManager.acquireQuery();\n const pairs = queryString.split('&');\n\n for (const pair of pairs) {\n const equalIndex = pair.indexOf('=');\n if (equalIndex === -1) {\n result[decodeURIComponent(pair)] = '';\n } else {\n const key = decodeURIComponent(pair.substring(0, equalIndex));\n const value = decodeURIComponent(pair.substring(equalIndex + 1));\n result[key] = value;\n }\n }\n return result;\n }\n\n private normalizePath(path: string): string {\n if (this.pathNormalizationCache.has(path)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.pathNormalizationCache.get(path)!;\n }\n\n let normalized = path;\n if (normalized.length > 1 && normalized.endsWith('/')) {\n normalized = normalized.slice(0, -1);\n }\n\n if (this.pathNormalizationCache.size < 200) {\n this.pathNormalizationCache.set(path, normalized);\n }\n\n return normalized;\n }\n\n private findRoute(method: string, path: string | undefined): RouteEntry | null {\n // Default to '/' if path is undefined\n const searchPath = path || '/';\n const cacheKey = `${method}:${searchPath}`;\n\n if (this.routeCache.has(cacheKey)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.routeCache.get(cacheKey)!;\n }\n\n const normalizedPath = this.normalizePath(searchPath);\n const normalizedCacheKey =\n normalizedPath !== searchPath ? `${method}:${normalizedPath}` : cacheKey;\n\n if (normalizedPath !== path && this.routeCache.has(normalizedCacheKey)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.routeCache.get(normalizedCacheKey)!;\n }\n\n const staticRoute = this.staticRoutes.get(normalizedCacheKey);\n if (staticRoute) {\n this.routeCache.set(normalizedCacheKey, staticRoute);\n if (normalizedPath !== path) {\n this.routeCache.set(cacheKey, staticRoute);\n }\n return staticRoute;\n }\n\n let route: RouteEntry | null = null;\n if (this.dynamicRoutes.length > 0) {\n const segmentCount = PathMatcher.countSegments(normalizedPath);\n const candidateRoutes = this.routesBySegmentCount.get(segmentCount) || this.dynamicRoutes;\n\n for (const candidateRoute of candidateRoutes) {\n if (candidateRoute.method === method && candidateRoute.pattern.test(normalizedPath)) {\n route = candidateRoute;\n break;\n }\n }\n }\n\n if (this.routeCache.size < 500) {\n this.routeCache.set(normalizedCacheKey, route);\n if (normalizedPath !== path) {\n this.routeCache.set(cacheKey, route);\n }\n }\n\n return route;\n }\n\n private async executeMiddleware(\n middleware: Middleware[],\n req: HttpRequest,\n res: HttpResponse\n ): Promise<void> {\n for (const mw of middleware) {\n if (res.headersSent) return;\n\n await new Promise<void>((resolve, reject) => {\n let resolved = false;\n\n const next = () => {\n if (resolved) return;\n resolved = true;\n resolve();\n };\n\n try {\n const result = mw(req, res, next);\n\n if (result && typeof result.then === 'function') {\n (result as Promise<void>)\n .then(() => {\n if (!resolved) next();\n })\n .catch(reject);\n } else if (!resolved) {\n next();\n }\n } catch (error) {\n if (!resolved) {\n resolved = true;\n reject(error);\n }\n }\n });\n }\n }\n\n listen(port: number, callback?: () => void): void;\n listen(port: number, host: string, callback?: () => void): void;\n listen(port: number, host?: string | (() => void), callback?: () => void): void {\n if (typeof host === 'function') {\n callback = host;\n host = undefined;\n }\n\n if (host) {\n this.server.listen(port, host, callback);\n } else {\n this.server.listen(port, callback);\n }\n }\n\n close(): Promise<void> {\n return new Promise(resolve => {\n this.server.close(() => resolve());\n });\n }\n\n forceCleanup(): void {\n this.poolManager.clearAll();\n if (globalThis?.gc) {\n globalThis.gc();\n }\n }\n\n getServer(): Http2Server | Http2SecureServer {\n return this.server;\n }\n\n getPerformanceStats() {\n const poolStats = this.poolManager.getStats();\n return {\n paramObjectPoolSize: poolStats.paramPool.poolSize,\n queryObjectPoolSize: poolStats.queryPool.poolSize,\n headerObjectPoolSize: poolStats.headerPool.poolSize,\n poolManager: poolStats,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http2-server.js","sourceRoot":"","sources":["../../../src/core/http/http2-server.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EACL,kBAAkB,IAAI,uBAAuB,EAC7C,YAAY,IAAI,iBAAiB,GAMlC,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EACL,cAAc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AM,CAAC;IACrB,CAAC;IAED,mBAAmB;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO;YACL,mBAAmB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;YACjD,mBAAmB,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;YACjD,oBAAoB,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ;YACnD,WAAW,EAAE,SAAS;SACvB,CAAC;IACJ,CAAC","sourcesContent":["// HTTP/2 Server Implementation for Moro Framework\nimport {\n createSecureServer as createHttp2SecureServer,\n createServer as createHttp2Server,\n Http2Server,\n Http2SecureServer,\n ServerHttp2Stream,\n IncomingHttpHeaders,\n OutgoingHttpHeaders,\n} from 'http2';\nimport * as zlib from 'zlib';\nimport { promisify } from 'util';\nimport { createFrameworkLogger } from '../logger/index.js';\nimport {\n HttpRequest,\n HttpResponse,\n Middleware,\n HttpHandler,\n RouteEntry,\n} from '../../types/http.js';\nimport { PathMatcher } from '../routing/path-matcher.js';\nimport { ObjectPoolManager } from '../pooling/object-pool-manager.js';\nimport {\n parseMultipart as parseMultipartBuffer,\n type MultipartLimits,\n} from './utils/multipart-parser.js';\nimport type { HttpRuntimeLimits } from './utils/size.js';\n\nconst gzip = promisify(zlib.gzip);\nconst deflate = promisify(zlib.deflate);\n\nexport interface Http2ServerOptions {\n key?: string | Buffer;\n cert?: string | Buffer;\n ca?: string | Buffer | Array<string | Buffer>;\n allowHTTP1?: boolean;\n maxSessionMemory?: number;\n maxBodySize?: number; // Maximum body size for JSON/form data\n maxUploadSize?: number; // Maximum size for file uploads\n /** Flattened runtime limits (timeouts, maxConnections, multipart, ...). */\n limits?: HttpRuntimeLimits;\n settings?: {\n headerTableSize?: number;\n enablePush?: boolean;\n initialWindowSize?: number;\n maxFrameSize?: number;\n maxConcurrentStreams?: number;\n maxHeaderListSize?: number;\n maxHeaderSize?: number;\n enableConnectProtocol?: boolean;\n };\n}\n\nexport class MoroHttp2Server {\n private server: Http2Server | Http2SecureServer;\n private routes: RouteEntry[] = [];\n private globalMiddleware: Middleware[] = [];\n private compressionEnabled = true;\n private compressionThreshold = 1024;\n private requestTrackingEnabled = true;\n private multipartLimits?: MultipartLimits;\n private _limits?: HttpRuntimeLimits;\n private logger = createFrameworkLogger('Http2Server');\n private hookManager: any;\n private requestCounter = 0;\n private isSecure: boolean;\n\n // Body size limits - defaults overridden by config in constructor\n private maxBodySize: number = 10 * 1024 * 1024; // Default 10MB (overridden by server.bodySizeLimit config)\n private maxUploadSize: number = 100 * 1024 * 1024; // Default 100MB for file uploads\n\n // Use shared object pool manager\n private poolManager = ObjectPoolManager.getInstance();\n\n // Interned method strings for fast comparison\n private static readonly METHOD_POST = 'POST';\n private static readonly METHOD_PUT = 'PUT';\n private static readonly METHOD_PATCH = 'PATCH';\n private static readonly METHOD_GET = 'GET';\n private static readonly METHOD_DELETE = 'DELETE';\n private static readonly METHOD_HEAD = 'HEAD';\n private static readonly METHOD_OPTIONS = 'OPTIONS';\n\n // Pre-compiled response templates\n private static readonly RESPONSE_TEMPLATES = {\n notFound: Buffer.from('{\"success\":false,\"error\":\"Not found\"}'),\n unauthorized: Buffer.from('{\"success\":false,\"error\":\"Unauthorized\"}'),\n forbidden: Buffer.from('{\"success\":false,\"error\":\"Forbidden\"}'),\n internalError: Buffer.from('{\"success\":false,\"error\":\"Internal server error\"}'),\n methodNotAllowed: Buffer.from('{\"success\":false,\"error\":\"Method not allowed\"}'),\n rateLimited: Buffer.from('{\"success\":false,\"error\":\"Rate limit exceeded\"}'),\n };\n\n // Route optimization structures\n private routeCache = new Map<string, RouteEntry | null>();\n private staticRoutes = new Map<string, RouteEntry>();\n private dynamicRoutes: RouteEntry[] = [];\n private routesBySegmentCount = new Map<number, RouteEntry[]>();\n private pathNormalizationCache = new Map<string, string>();\n\n constructor(options: Http2ServerOptions = {}) {\n this.isSecure = !!(options.key && options.cert);\n\n // Configure body size limits from options\n if (options.maxBodySize) {\n this.maxBodySize = options.maxBodySize;\n }\n if (options.maxUploadSize) {\n this.maxUploadSize = options.maxUploadSize;\n }\n if (options.limits?.multipart) this.multipartLimits = options.limits.multipart;\n if (options.limits) this._limits = options.limits;\n\n const serverOptions: any = {\n allowHTTP1: options.allowHTTP1 !== false,\n ...(options.maxSessionMemory && { maxSessionMemory: options.maxSessionMemory }),\n };\n\n // Add SSL options if secure\n if (this.isSecure) {\n serverOptions.key = options.key;\n serverOptions.cert = options.cert;\n if (options.ca) {\n serverOptions.ca = options.ca;\n }\n }\n\n // Add HTTP/2 settings\n if (options.settings) {\n serverOptions.settings = {\n headerTableSize: options.settings.headerTableSize,\n enablePush: options.settings.enablePush !== false,\n initialWindowSize: options.settings.initialWindowSize || 65535,\n maxFrameSize: options.settings.maxFrameSize || 16384,\n maxConcurrentStreams: options.settings.maxConcurrentStreams || 100,\n maxHeaderListSize: options.settings.maxHeaderListSize,\n maxHeaderSize: options.settings.maxHeaderSize,\n enableConnectProtocol: options.settings.enableConnectProtocol,\n };\n } else {\n serverOptions.settings = {\n enablePush: true,\n initialWindowSize: 65535,\n maxFrameSize: 16384,\n maxConcurrentStreams: 100,\n };\n }\n\n // Create server\n if (this.isSecure) {\n this.server = createHttp2SecureServer(serverOptions);\n this.logger.info('HTTP/2 secure server created', 'ServerInit');\n } else {\n this.server = createHttp2Server(serverOptions);\n this.logger.info('HTTP/2 server created', 'ServerInit');\n }\n\n // Configure server settings. Socket idle timeout defaults to 30s (its\n // historical hardcode) unless timeouts.idle is set (0 disables).\n this.server.setTimeout(options.limits?.timeouts?.idle ?? 30000);\n if (options.limits?.maxConnections && options.limits.maxConnections > 0) {\n (this.server as any).maxConnections = options.limits.maxConnections;\n }\n\n // Handle streams (HTTP/2 requests). Wrap so the async handler's promise is\n // always caught - a rejection escaping here becomes an unhandled rejection\n // that can crash the process.\n this.server.on('stream', (stream: ServerHttp2Stream, headers: IncomingHttpHeaders) => {\n void this.handleStream(stream, headers).catch(error => {\n this.logger.error('Unhandled HTTP/2 stream error', 'StreamError', {\n error: error instanceof Error ? error.message : String(error),\n });\n });\n });\n\n // Handle session events\n this.server.on('session', session => {\n this.logger.debug('HTTP/2 session created', 'Session');\n\n session.on('error', err => {\n this.logger.error('HTTP/2 session error', 'Session', { error: err.message });\n });\n });\n\n // Handle server errors\n this.server.on('error', err => {\n this.logger.error('HTTP/2 server error', 'ServerError', { error: err.message });\n });\n }\n\n // Configure server for maximum performance\n configurePerformance(\n config: { compression?: { enabled: boolean; threshold?: number }; minimal?: boolean } = {}\n ) {\n if (config.compression !== undefined) {\n this.compressionEnabled = config.compression.enabled;\n if (config.compression.threshold !== undefined) {\n this.compressionThreshold = config.compression.threshold;\n }\n }\n\n if (config.minimal) {\n this.compressionEnabled = false;\n this.compressionThreshold = Infinity;\n }\n }\n\n // Configure request tracking\n setRequestTracking(enabled: boolean): void {\n this.requestTrackingEnabled = enabled;\n }\n\n // Middleware management\n use(middleware: Middleware): void {\n // Defensive check: Don't add MiddlewareInterface objects to globalMiddleware\n // MiddlewareInterface objects should only be handled by MiddlewareManager\n if (\n middleware &&\n typeof middleware === 'object' &&\n (middleware as any).install &&\n (middleware as any).metadata\n ) {\n this.logger?.warn?.(\n `Attempted to add MiddlewareInterface \"${(middleware as any).metadata?.name}\" to HTTP server globalMiddleware. ` +\n `This should be handled by MiddlewareManager instead. Skipping.`,\n 'Middleware'\n );\n return;\n }\n\n this.globalMiddleware.push(middleware);\n }\n\n // Set hooks manager\n setHookManager(hookManager: any): void {\n this.hookManager = hookManager;\n }\n\n // Routing methods\n get(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('GET', path, handlers);\n }\n\n post(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('POST', path, handlers);\n }\n\n put(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('PUT', path, handlers);\n }\n\n delete(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('DELETE', path, handlers);\n }\n\n patch(path: string, ...handlers: (Middleware | HttpHandler)[]): void {\n this.addRoute('PATCH', path, handlers);\n }\n\n private addRoute(method: string, path: string, handlers: (Middleware | HttpHandler)[]): void {\n const { pattern, paramNames } = this.pathToRegex(path);\n const handler = handlers.pop() as HttpHandler;\n const middleware = handlers as Middleware[];\n\n const route = {\n method,\n path,\n pattern,\n paramNames,\n handler,\n middleware,\n };\n\n this.routes.push(route);\n\n // Organize routes for optimal lookup\n if (paramNames.length === 0) {\n const staticKey = `${method}:${path}`;\n this.staticRoutes.set(staticKey, route);\n } else {\n this.dynamicRoutes.push(route);\n const segmentCount = PathMatcher.countSegments(path);\n if (!this.routesBySegmentCount.has(segmentCount)) {\n this.routesBySegmentCount.set(segmentCount, []);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.routesBySegmentCount.get(segmentCount)!.push(route);\n }\n }\n\n private pathToRegex(path: string): { pattern: RegExp; paramNames: string[] } {\n const compiled = PathMatcher.compile(path);\n return {\n pattern: compiled.pattern || new RegExp(`^${path.replace(/\\//g, '\\\\/')}$`),\n paramNames: compiled.paramNames,\n };\n }\n\n private async handleStream(\n stream: ServerHttp2Stream,\n headers: IncomingHttpHeaders\n ): Promise<void> {\n this.requestCounter++;\n\n const httpReq = this.createRequestFromStream(stream, headers);\n const httpRes = this.createResponseFromStream(stream, httpReq);\n\n try {\n // Parse URL and query\n const url = (headers[':path'] as string) || '/';\n const queryIndex = url.indexOf('?');\n\n if (queryIndex === -1) {\n httpReq.path = url;\n httpReq.query = {};\n } else {\n httpReq.path = url.substring(0, queryIndex);\n httpReq.query = this.parseQueryString(url.substring(queryIndex + 1));\n }\n\n // Parse body for POST/PUT/PATCH\n const method = httpReq.method;\n if (\n method === MoroHttp2Server.METHOD_POST ||\n method === MoroHttp2Server.METHOD_PUT ||\n method === MoroHttp2Server.METHOD_PATCH\n ) {\n httpReq.body = await this.parseBody(stream, headers);\n }\n\n // Execute hooks\n if (this.hookManager) {\n await this.hookManager.execute('request', {\n request: httpReq,\n response: httpRes,\n });\n\n // Post-response hooks. The HTTP/2 response object is a plain object\n // (no event emitter), so listen on the underlying stream instead.\n if (this.hookManager.hasHooks === undefined || this.hookManager.hasHooks('response')) {\n stream.once('close', () => {\n void Promise.resolve(\n this.hookManager.execute('response', { request: httpReq, response: httpRes })\n ).catch((error: any) =>\n this.logger?.error?.(`Response hook error: ${error?.message || error}`, 'Hooks')\n );\n });\n }\n }\n\n // Execute global middleware\n if (this.globalMiddleware.length > 0) {\n await this.executeMiddleware(this.globalMiddleware, httpReq, httpRes);\n }\n\n // If middleware handled the request, don't continue\n if (httpRes.headersSent) {\n return;\n }\n\n // Find matching route (path is always set after URL parsing)\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const route = this.findRoute(method || MoroHttp2Server.METHOD_GET, httpReq.path!);\n if (!route) {\n httpRes.statusCode = 404;\n httpRes.setHeader('Content-Type', 'application/json; charset=utf-8');\n httpRes.setHeader('Content-Length', MoroHttp2Server.RESPONSE_TEMPLATES.notFound.length);\n httpRes.end(MoroHttp2Server.RESPONSE_TEMPLATES.notFound);\n return;\n }\n\n // Extract path parameters\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const matches = httpReq.path!.match(route.pattern);\n if (matches) {\n httpReq.params = this.poolManager.acquireParams();\n const paramNames = route.paramNames;\n for (let i = 0; i < paramNames.length; i++) {\n const paramName = paramNames[i];\n const value = matches[i + 1];\n if (paramName !== undefined && value !== undefined) {\n httpReq.params[paramName] = value;\n }\n }\n }\n\n // Execute route middleware\n if (route.middleware.length > 0) {\n await this.executeMiddleware(route.middleware, httpReq, httpRes);\n }\n\n // Execute handler\n const handlerResult = route.handler(httpReq, httpRes);\n if (handlerResult && typeof handlerResult.then === 'function') {\n await handlerResult;\n }\n } catch (error) {\n this.logger.error('HTTP/2 stream error', 'StreamError', {\n error: error instanceof Error ? error.message : String(error),\n requestId: httpReq.requestId,\n path: httpReq.path,\n });\n\n // Error hooks are observational: fire-and-forget so a slow or throwing\n // observer can never delay or alter the error response.\n if (\n this.hookManager &&\n (this.hookManager.hasHooks === undefined || this.hookManager.hasHooks('error'))\n ) {\n void Promise.resolve(\n this.hookManager.execute('error', { request: httpReq, response: httpRes, error })\n ).catch((hookError: any) =>\n this.logger?.error?.(`Error hook error: ${hookError?.message || hookError}`, 'Hooks')\n );\n }\n\n if (!httpRes.headersSent) {\n httpRes.status(500).json({\n success: false,\n error: 'Internal server error',\n requestId: httpReq.requestId,\n });\n }\n } finally {\n // Release pooled objects\n if (httpReq.params && Object.keys(httpReq.params).length === 0) {\n this.poolManager.releaseParams(httpReq.params);\n }\n if (httpReq.query && Object.keys(httpReq.query).length === 0) {\n this.poolManager.releaseQuery(httpReq.query);\n }\n }\n }\n\n private createRequestFromStream(\n stream: ServerHttp2Stream,\n headers: IncomingHttpHeaders\n ): HttpRequest {\n // Extract method from pseudo-header\n const methodRaw = ((headers[':method'] as string) || 'GET').toUpperCase();\n\n // Intern method string for fast comparison\n let method: string;\n switch (methodRaw) {\n case 'POST':\n method = MoroHttp2Server.METHOD_POST;\n break;\n case 'PUT':\n method = MoroHttp2Server.METHOD_PUT;\n break;\n case 'PATCH':\n method = MoroHttp2Server.METHOD_PATCH;\n break;\n case 'GET':\n method = MoroHttp2Server.METHOD_GET;\n break;\n case 'DELETE':\n method = MoroHttp2Server.METHOD_DELETE;\n break;\n case 'HEAD':\n method = MoroHttp2Server.METHOD_HEAD;\n break;\n case 'OPTIONS':\n method = MoroHttp2Server.METHOD_OPTIONS;\n break;\n default:\n method = methodRaw;\n }\n\n // Convert HTTP/2 headers to standard headers (remove pseudo-headers)\n const standardHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (!key.startsWith(':')) {\n standardHeaders[key] = Array.isArray(value) ? value.join(', ') : (value as string);\n }\n }\n\n // Parse cookies\n const cookieHeader = standardHeaders['cookie'];\n const cookies: Record<string, string> = {};\n if (cookieHeader) {\n const cookieParts = cookieHeader.split(';');\n for (const cookie of cookieParts) {\n const equalIndex = cookie.indexOf('=');\n if (equalIndex > 0) {\n const name = cookie.substring(0, equalIndex).trim();\n const value = cookie.substring(equalIndex + 1);\n if (name && value) {\n try {\n cookies[name] = decodeURIComponent(value);\n } catch {\n // Malformed percent-encoding: keep the raw value rather than\n // throwing a URIError. createRequestFromStream runs before\n // handleStream's try block, so an escape here would surface as\n // an unhandled rejection and crash the process.\n cookies[name] = value;\n }\n }\n }\n }\n }\n\n const httpReq: HttpRequest = {\n method,\n path: '',\n url: (headers[':path'] as string) || '/',\n query: {},\n params: {},\n headers: standardHeaders,\n body: null,\n cookies,\n ip: (stream.session?.socket as any)?.remoteAddress || '',\n requestId: this.requestTrackingEnabled ? this.poolManager.generateRequestId() : '',\n httpVersion: '2.0',\n } as HttpRequest;\n\n // Store stream reference for push capability\n (httpReq as any)._http2Stream = stream;\n (httpReq as any)._http2Headers = headers;\n\n return httpReq;\n }\n\n private createResponseFromStream(stream: ServerHttp2Stream, req: HttpRequest): HttpResponse {\n const httpRes: any = {\n statusCode: 200,\n headersSent: false,\n _headers: {} as OutgoingHttpHeaders,\n _stream: stream,\n _req: req,\n _logger: this.logger,\n _poolManager: this.poolManager,\n _compressionEnabled: this.compressionEnabled,\n _compressionThreshold: this.compressionThreshold,\n };\n\n // Status method\n httpRes.status = (code: number) => {\n httpRes.statusCode = code;\n return httpRes;\n };\n\n // Set header\n httpRes.setHeader = (name: string, value: string | string[]) => {\n httpRes._headers[name.toLowerCase()] = value;\n return httpRes;\n };\n\n // Get header\n httpRes.getHeader = (name: string) => {\n return httpRes._headers[name.toLowerCase()];\n };\n\n // Remove header\n httpRes.removeHeader = (name: string) => {\n delete httpRes._headers[name.toLowerCase()];\n return httpRes;\n };\n\n // Has header\n httpRes.hasHeader = (name: string): boolean => {\n return httpRes._headers[name.toLowerCase()] !== undefined;\n };\n\n // Get headers\n httpRes.getHeaders = () => {\n return { ...httpRes._headers };\n };\n\n // JSON response\n httpRes.json = async (data: any) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n const jsonString = JSON.stringify(data);\n const finalBuffer = Buffer.from(jsonString, 'utf8');\n\n httpRes._headers['content-type'] = 'application/json; charset=utf-8';\n\n // Compression\n if (httpRes._compressionEnabled && finalBuffer.length > httpRes._compressionThreshold) {\n const acceptEncoding = req.headers['accept-encoding'];\n\n if (acceptEncoding && acceptEncoding.includes('gzip')) {\n const compressed = await gzip(finalBuffer);\n httpRes._headers['content-encoding'] = 'gzip';\n httpRes._headers['content-length'] = compressed.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(compressed);\n httpRes.headersSent = true;\n return;\n } else if (acceptEncoding && acceptEncoding.includes('deflate')) {\n const compressed = await deflate(finalBuffer);\n httpRes._headers['content-encoding'] = 'deflate';\n httpRes._headers['content-length'] = compressed.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(compressed);\n httpRes.headersSent = true;\n return;\n }\n }\n\n httpRes._headers['content-length'] = finalBuffer.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(finalBuffer);\n httpRes.headersSent = true;\n };\n\n // Send response\n httpRes.send = (data: string | Buffer) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n if (!httpRes._headers['content-type']) {\n if (typeof data === 'string') {\n try {\n JSON.parse(data);\n httpRes._headers['content-type'] = 'application/json; charset=utf-8';\n } catch {\n httpRes._headers['content-type'] = 'text/plain; charset=utf-8';\n }\n } else {\n httpRes._headers['content-type'] = 'application/octet-stream';\n }\n }\n\n const buffer = typeof data === 'string' ? Buffer.from(data) : data;\n httpRes._headers['content-length'] = buffer.length;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(buffer);\n httpRes.headersSent = true;\n };\n\n // End response\n httpRes.end = (data?: any) => {\n if (httpRes.headersSent || stream.destroyed) return httpRes;\n\n stream.respond({\n ':status': httpRes.statusCode,\n ...httpRes._headers,\n });\n stream.end(data || '');\n httpRes.headersSent = true;\n return httpRes;\n };\n\n // Standardized response helpers\n httpRes.success = <T = any>(data: T, message?: string) => {\n const response: any = {\n success: true,\n data,\n };\n if (message !== undefined) {\n response.message = message;\n }\n httpRes.json(response);\n };\n\n httpRes.error = (error: string, code?: string, message?: string) => {\n const response: any = {\n success: false,\n error,\n };\n if (code !== undefined) {\n response.code = code;\n }\n if (message !== undefined) {\n response.message = message;\n }\n httpRes.json(response);\n };\n\n // Common HTTP error helpers (automatically set status code)\n httpRes.unauthorized = (message: string = 'Authentication required') => {\n httpRes.statusCode = 401;\n httpRes.json({\n success: false,\n error: 'Unauthorized',\n code: 'UNAUTHORIZED',\n message,\n });\n };\n\n httpRes.forbidden = (message: string = 'Insufficient permissions') => {\n httpRes.statusCode = 403;\n httpRes.json({\n success: false,\n error: 'Forbidden',\n code: 'FORBIDDEN',\n message,\n });\n };\n\n httpRes.notFound = (resource: string = 'Resource') => {\n httpRes.statusCode = 404;\n httpRes.json({\n success: false,\n error: 'Not Found',\n code: 'NOT_FOUND',\n message: `${resource} not found`,\n });\n };\n\n httpRes.badRequest = (message: string = 'Invalid request') => {\n httpRes.statusCode = 400;\n httpRes.json({\n success: false,\n error: 'Bad Request',\n code: 'BAD_REQUEST',\n message,\n });\n };\n\n httpRes.conflict = (message: string) => {\n httpRes.statusCode = 409;\n httpRes.json({\n success: false,\n error: 'Conflict',\n code: 'CONFLICT',\n message,\n });\n };\n\n httpRes.internalError = (message: string = 'Internal server error') => {\n httpRes.statusCode = 500;\n httpRes.json({\n success: false,\n error: 'Internal Server Error',\n code: 'INTERNAL_ERROR',\n message,\n });\n };\n\n httpRes.validationError = (\n errors: Array<{ field: string; message: string; code?: string }>\n ) => {\n httpRes.statusCode = 422;\n httpRes.json({\n success: false,\n error: 'Validation Failed',\n code: 'VALIDATION_ERROR',\n errors,\n });\n };\n\n httpRes.rateLimited = (retryAfter?: number) => {\n httpRes.statusCode = 429;\n if (retryAfter) {\n httpRes.setHeader('Retry-After', retryAfter.toString());\n }\n httpRes.json({\n success: false,\n error: 'Rate Limit Exceeded',\n code: 'RATE_LIMITED',\n message: retryAfter\n ? `Too many requests. Retry after ${retryAfter} seconds.`\n : 'Too many requests',\n retryAfter,\n });\n };\n\n // Common success patterns\n httpRes.created = <T = any>(data: T, location?: string) => {\n httpRes.statusCode = 201;\n if (location) {\n httpRes.setHeader('Location', location);\n }\n httpRes.json({\n success: true,\n data,\n });\n };\n\n httpRes.noContent = () => {\n httpRes.statusCode = 204;\n httpRes.end();\n };\n\n httpRes.paginated = <T = any>(\n data: T[],\n pagination: { page: number; limit: number; total: number }\n ) => {\n const totalPages = Math.ceil(pagination.total / pagination.limit);\n httpRes.json({\n success: true,\n data,\n pagination: {\n page: pagination.page,\n limit: pagination.limit,\n total: pagination.total,\n totalPages,\n hasNext: pagination.page < totalPages,\n hasPrev: pagination.page > 1,\n },\n });\n };\n\n // Cookie handling\n httpRes.cookie = (name: string, value: string, options: any = {}) => {\n if (httpRes.headersSent) {\n const isCritical = options.critical || name.includes('session') || name.includes('auth');\n const message = `Cookie '${name}' could not be set - headers already sent`;\n\n if (isCritical || options.throwOnLateSet) {\n throw new Error(`${message}. This may cause authentication or security issues.`);\n } else {\n httpRes._logger.warn(message, 'CookieWarning', { cookieName: name });\n }\n return httpRes;\n }\n\n const cookieValue = encodeURIComponent(value);\n let cookieString = `${name}=${cookieValue}`;\n\n if (options.maxAge) cookieString += `; Max-Age=${options.maxAge}`;\n if (options.expires) cookieString += `; Expires=${options.expires.toUTCString()}`;\n if (options.httpOnly) cookieString += '; HttpOnly';\n if (options.secure) cookieString += '; Secure';\n if (options.sameSite) cookieString += `; SameSite=${options.sameSite}`;\n if (options.domain) cookieString += `; Domain=${options.domain}`;\n if (options.path) cookieString += `; Path=${options.path}`;\n\n const existingCookies = httpRes._headers['set-cookie'] || [];\n const cookies = Array.isArray(existingCookies)\n ? existingCookies\n : [existingCookies as string];\n cookies.push(cookieString);\n httpRes._headers['set-cookie'] = cookies;\n\n return httpRes;\n };\n\n // Clear cookie\n httpRes.clearCookie = (name: string, options: any = {}) => {\n return httpRes.cookie(name, '', {\n expires: new Date(0),\n maxAge: 0,\n ...options,\n });\n };\n\n // Redirect\n httpRes.redirect = (url: string, status: number = 302) => {\n if (httpRes.headersSent || stream.destroyed) return;\n\n httpRes.statusCode = status;\n httpRes._headers['location'] = url;\n\n stream.respond({\n ':status': status,\n ...httpRes._headers,\n });\n stream.end();\n httpRes.headersSent = true;\n };\n\n // HTTP/2 Server Push\n httpRes.push = (\n path: string,\n options: { headers?: OutgoingHttpHeaders; priority?: number } = {}\n ) => {\n if (httpRes.headersSent || stream.destroyed || !stream.pushAllowed) {\n return null;\n }\n\n try {\n const pushHeaders: any = {\n ':path': path,\n ':method': 'GET',\n ...options.headers,\n };\n\n const pushStream = stream.pushStream(pushHeaders, err => {\n if (err) {\n httpRes._logger.debug('Server push failed', 'ServerPush', {\n path,\n error: err.message,\n });\n }\n });\n\n // Set stream priority if specified\n if (options.priority !== undefined && pushStream) {\n try {\n // Priority weight: 1-256 (default 16)\n // Higher values = higher priority\n const weight = Math.max(1, Math.min(256, options.priority));\n (pushStream as any).priority({\n parent: 0,\n weight,\n exclusive: false,\n });\n } catch (error) {\n httpRes._logger.debug('Failed to set stream priority', 'StreamPriority', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return pushStream;\n } catch (error) {\n httpRes._logger.debug('Server push error', 'ServerPush', {\n path,\n error: error instanceof Error ? error.message : String(error),\n });\n return null;\n }\n };\n\n // Set stream priority for current response\n httpRes.setPriority = (\n options: { parent?: number; weight?: number; exclusive?: boolean } = {}\n ) => {\n if (httpRes.headersSent || stream.destroyed) {\n return httpRes;\n }\n\n try {\n stream.priority({\n parent: options.parent || 0,\n weight: options.weight ? Math.max(1, Math.min(256, options.weight)) : 16,\n exclusive: options.exclusive || false,\n });\n } catch (error) {\n httpRes._logger.debug('Failed to set stream priority', 'StreamPriority', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n\n return httpRes;\n };\n\n // Set bulk headers\n httpRes.setBulkHeaders = (headers: Record<string, string | number>) => {\n if (httpRes.headersSent) {\n httpRes._logger.warn('Cannot set headers - headers already sent', 'HeaderWarning');\n return httpRes;\n }\n\n for (const key in headers) {\n httpRes._headers[key.toLowerCase()] = String(headers[key]);\n }\n return httpRes;\n };\n\n // Response state\n httpRes.canSetHeaders = (): boolean => {\n return !httpRes.headersSent;\n };\n\n httpRes.getResponseState = () => {\n return {\n headersSent: httpRes.headersSent,\n statusCode: httpRes.statusCode,\n headers: httpRes.getHeaders(),\n finished: stream.destroyed,\n writable: !stream.destroyed,\n };\n };\n\n return httpRes as HttpResponse;\n }\n\n private async parseBody(stream: ServerHttp2Stream, headers: IncomingHttpHeaders): Promise<any> {\n const contentType = (headers['content-type'] as string) || '';\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const contentLength = parseInt((headers['content-length'] as string) || '0');\n\n // Use different limits based on content type\n const isMultipart = contentType.includes('multipart/form-data');\n const maxSize = isMultipart\n ? this.maxUploadSize // Configurable file upload limit (default 100MB)\n : this.maxBodySize; // Configurable body size limit (default 10MB, from server.bodySizeLimit config)\n\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let totalLength = 0;\n\n stream.on('data', (chunk: Buffer) => {\n totalLength += chunk.length;\n if (totalLength > maxSize) {\n const errorMessage = isMultipart\n ? `File upload too large. Maximum ${Math.floor(maxSize / (1024 * 1024))}MB allowed.`\n : 'Request body too large';\n reject(new Error(errorMessage));\n return;\n }\n chunks.push(chunk);\n });\n\n stream.on('end', () => {\n try {\n const body = Buffer.concat(chunks);\n\n if (contentType.includes('application/json')) {\n resolve(JSON.parse(body.toString()));\n } else if (contentType.includes('application/x-www-form-urlencoded')) {\n resolve(this.parseUrlEncoded(body.toString()));\n } else if (contentType.includes('multipart/form-data')) {\n resolve(parseMultipartBuffer(body, contentType, this.multipartLimits));\n } else {\n resolve(body.toString());\n }\n } catch (error) {\n reject(error);\n }\n });\n\n stream.on('error', reject);\n });\n }\n\n private parseUrlEncoded(body: string): Record<string, string> {\n const params = new URLSearchParams(body);\n const result: Record<string, string> = {};\n for (const [key, value] of params) {\n result[key] = value;\n }\n return result;\n }\n\n private parseQueryString(queryString: string): Record<string, string> {\n if (!queryString) return {};\n\n const result = this.poolManager.acquireQuery();\n const pairs = queryString.split('&');\n\n for (const pair of pairs) {\n const equalIndex = pair.indexOf('=');\n if (equalIndex === -1) {\n result[decodeURIComponent(pair)] = '';\n } else {\n const key = decodeURIComponent(pair.substring(0, equalIndex));\n const value = decodeURIComponent(pair.substring(equalIndex + 1));\n result[key] = value;\n }\n }\n return result;\n }\n\n private normalizePath(path: string): string {\n if (this.pathNormalizationCache.has(path)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.pathNormalizationCache.get(path)!;\n }\n\n let normalized = path;\n if (normalized.length > 1 && normalized.endsWith('/')) {\n normalized = normalized.slice(0, -1);\n }\n\n if (this.pathNormalizationCache.size < 200) {\n this.pathNormalizationCache.set(path, normalized);\n }\n\n return normalized;\n }\n\n private findRoute(method: string, path: string | undefined): RouteEntry | null {\n // Default to '/' if path is undefined\n const searchPath = path || '/';\n const cacheKey = `${method}:${searchPath}`;\n\n if (this.routeCache.has(cacheKey)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.routeCache.get(cacheKey)!;\n }\n\n const normalizedPath = this.normalizePath(searchPath);\n const normalizedCacheKey =\n normalizedPath !== searchPath ? `${method}:${normalizedPath}` : cacheKey;\n\n if (normalizedPath !== path && this.routeCache.has(normalizedCacheKey)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.routeCache.get(normalizedCacheKey)!;\n }\n\n const staticRoute = this.staticRoutes.get(normalizedCacheKey);\n if (staticRoute) {\n this.routeCache.set(normalizedCacheKey, staticRoute);\n if (normalizedPath !== path) {\n this.routeCache.set(cacheKey, staticRoute);\n }\n return staticRoute;\n }\n\n let route: RouteEntry | null = null;\n if (this.dynamicRoutes.length > 0) {\n const segmentCount = PathMatcher.countSegments(normalizedPath);\n const candidateRoutes = this.routesBySegmentCount.get(segmentCount) || this.dynamicRoutes;\n\n for (const candidateRoute of candidateRoutes) {\n if (candidateRoute.method === method && candidateRoute.pattern.test(normalizedPath)) {\n route = candidateRoute;\n break;\n }\n }\n }\n\n if (this.routeCache.size < 500) {\n this.routeCache.set(normalizedCacheKey, route);\n if (normalizedPath !== path) {\n this.routeCache.set(cacheKey, route);\n }\n }\n\n return route;\n }\n\n private async executeMiddleware(\n middleware: Middleware[],\n req: HttpRequest,\n res: HttpResponse\n ): Promise<void> {\n for (const mw of middleware) {\n if (res.headersSent) return;\n\n await new Promise<void>((resolve, reject) => {\n let resolved = false;\n\n const next = () => {\n if (resolved) return;\n resolved = true;\n resolve();\n };\n\n try {\n const result = mw(req, res, next);\n\n if (result && typeof result.then === 'function') {\n (result as Promise<void>)\n .then(() => {\n if (!resolved) next();\n })\n .catch(reject);\n } else if (!resolved) {\n next();\n }\n } catch (error) {\n if (!resolved) {\n resolved = true;\n reject(error);\n }\n }\n });\n }\n }\n\n listen(port: number, callback?: () => void): void;\n listen(port: number, host: string, callback?: () => void): void;\n listen(port: number, host?: string | (() => void), callback?: () => void): void {\n if (typeof host === 'function') {\n callback = host;\n host = undefined;\n }\n\n if (host) {\n this.server.listen(port, host, callback);\n } else {\n this.server.listen(port, callback);\n }\n }\n\n close(): Promise<void> {\n return new Promise(resolve => {\n this.server.close(() => resolve());\n });\n }\n\n forceCleanup(): void {\n this.poolManager.clearAll();\n if (globalThis?.gc) {\n globalThis.gc();\n }\n }\n\n getServer(): Http2Server | Http2SecureServer {\n return this.server;\n }\n\n getPerformanceStats() {\n const poolStats = this.poolManager.getStats();\n return {\n paramObjectPoolSize: poolStats.paramPool.poolSize,\n queryObjectPoolSize: poolStats.queryPool.poolSize,\n headerObjectPoolSize: poolStats.headerPool.poolSize,\n poolManager: poolStats,\n };\n }\n}\n"]}
|
|
@@ -1660,6 +1660,13 @@ export class MoroEngineServer {
|
|
|
1660
1660
|
response: httpRes,
|
|
1661
1661
|
});
|
|
1662
1662
|
}
|
|
1663
|
+
// Post-response hooks (session persistence, auth session refresh, CDN
|
|
1664
|
+
// invalidation) run after the response is flushed, off the critical path.
|
|
1665
|
+
if (hookManager && (hookManager.hasHooks === undefined || hookManager.hasHooks('response'))) {
|
|
1666
|
+
httpRes.once('finish', () => {
|
|
1667
|
+
void Promise.resolve(hookManager.execute('response', { request: httpReq, response: httpRes })).catch((error) => this.logger?.error?.(`Response hook error: ${error?.message || error}`, 'Hooks'));
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1663
1670
|
// Execute global middleware chain
|
|
1664
1671
|
if (this.globalMiddleware.length > 0) {
|
|
1665
1672
|
await this.executeMiddleware(this.globalMiddleware, httpReq, httpRes);
|
|
@@ -1711,6 +1718,12 @@ export class MoroEngineServer {
|
|
|
1711
1718
|
return;
|
|
1712
1719
|
}
|
|
1713
1720
|
this.logger.error(`Request handling error: ${error instanceof Error ? error.message : String(error)}`, 'RequestError');
|
|
1721
|
+
// Error hooks are observational: fire-and-forget so a slow or throwing
|
|
1722
|
+
// observer can never delay or alter the error response.
|
|
1723
|
+
const errorHooks = this.hookManager;
|
|
1724
|
+
if (errorHooks && (errorHooks.hasHooks === undefined || errorHooks.hasHooks('error'))) {
|
|
1725
|
+
void Promise.resolve(errorHooks.execute('error', { request: httpReq, response: httpRes, error })).catch((hookError) => this.logger?.error?.(`Error hook error: ${hookError?.message || hookError}`, 'Hooks'));
|
|
1726
|
+
}
|
|
1714
1727
|
// The app's global error handler (Moro.setErrorHandler) gets first shot
|
|
1715
1728
|
// at shaping the response - same contract as the Node server.
|
|
1716
1729
|
if (this.errorHandler && !httpRes.writableEnded && !httpRes.headersSent) {
|