@morojs/moro 1.8.7 → 1.8.9
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/http/http-server.js +4 -0
- package/dist/core/http/http-server.js.map +1 -1
- package/dist/core/http/http2-server.js +4 -0
- package/dist/core/http/http2-server.js.map +1 -1
- package/dist/core/http/moro-engine-server.d.ts +1 -0
- package/dist/core/http/moro-engine-server.js +108 -35
- package/dist/core/http/moro-engine-server.js.map +1 -1
- package/dist/core/http/uws-http-server.d.ts +1 -0
- package/dist/core/http/uws-http-server.js +106 -20
- package/dist/core/http/uws-http-server.js.map +1 -1
- package/dist/core/middleware/built-in/cookie/core.d.ts +26 -1
- package/dist/core/middleware/built-in/cookie/core.js +70 -2
- package/dist/core/middleware/built-in/cookie/core.js.map +1 -1
- package/dist/core/middleware/built-in/cookie/hook.d.ts +3 -1
- package/dist/core/middleware/built-in/cookie/hook.js +17 -5
- package/dist/core/middleware/built-in/cookie/hook.js.map +1 -1
- package/dist/core/middleware/built-in/cookie/index.d.ts +1 -1
- package/dist/core/middleware/built-in/cookie/index.js +1 -1
- package/dist/core/middleware/built-in/cookie/index.js.map +1 -1
- package/dist/core/middleware/built-in/cookie/middleware.d.ts +1 -1
- package/dist/core/middleware/built-in/cookie/middleware.js +6 -4
- package/dist/core/middleware/built-in/cookie/middleware.js.map +1 -1
- package/dist/core/middleware/built-in/index.d.ts +4 -12
- package/dist/core/middleware/built-in/rate-limit/core.d.ts +24 -0
- package/dist/core/middleware/built-in/rate-limit/core.js +47 -0
- package/dist/core/middleware/built-in/rate-limit/core.js.map +1 -1
- package/dist/core/middleware/built-in/rate-limit/hook.d.ts +24 -9
- package/dist/core/middleware/built-in/rate-limit/hook.js +34 -12
- package/dist/core/middleware/built-in/rate-limit/hook.js.map +1 -1
- package/dist/core/middleware/built-in/rate-limit/middleware.js +9 -1
- package/dist/core/middleware/built-in/rate-limit/middleware.js.map +1 -1
- package/dist/core/middleware/built-in/session/core.d.ts +8 -0
- package/dist/core/middleware/built-in/session/core.js +29 -2
- package/dist/core/middleware/built-in/session/core.js.map +1 -1
- package/dist/core/middleware/built-in/session/hook.js +2 -3
- package/dist/core/middleware/built-in/session/hook.js.map +1 -1
- package/dist/core/middleware/built-in/session/middleware.js +2 -3
- package/dist/core/middleware/built-in/session/middleware.js.map +1 -1
- package/dist/core/middleware/built-in/static/core.d.ts +56 -0
- package/dist/core/middleware/built-in/static/core.js +214 -13
- package/dist/core/middleware/built-in/static/core.js.map +1 -1
- package/dist/core/middleware/built-in/static/middleware.d.ts +5 -0
- package/dist/core/middleware/built-in/static/middleware.js +5 -0
- package/dist/core/middleware/built-in/static/middleware.js.map +1 -1
- package/dist/core/middleware/built-in/upload/core.d.ts +17 -0
- package/dist/core/middleware/built-in/upload/core.js +30 -1
- package/dist/core/middleware/built-in/upload/core.js.map +1 -1
- package/dist/core/middleware/built-in/upload/middleware.js +12 -1
- package/dist/core/middleware/built-in/upload/middleware.js.map +1 -1
- package/dist/core/routing/index.d.ts +1 -0
- package/dist/core/routing/index.js.map +1 -1
- package/dist/core/routing/unified-router.js +60 -29
- package/dist/core/routing/unified-router.js.map +1 -1
- package/dist/index.d.ts +2 -6
- package/dist/types/http.d.ts +3 -0
- package/dist/types/http.js.map +1 -1
- package/package.json +1 -1
|
@@ -269,6 +269,10 @@ export class MoroHttp2Server {
|
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
+
// A request hook may answer the request itself (rate limiting, auth
|
|
273
|
+
// rejection). Registration of the response hooks above still stands.
|
|
274
|
+
if (httpRes.headersSent)
|
|
275
|
+
return;
|
|
272
276
|
// Execute global middleware
|
|
273
277
|
if (this.globalMiddleware.length > 0) {
|
|
274
278
|
await this.executeMiddleware(this.globalMiddleware, httpReq, httpRes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http2-server.js","sourceRoot":"","sources":["../../../src/core/http/http2-server.ts"],"names":[],"mappings":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CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAID,MAAM,CAAC,IAAY,EAAE,IAA4B,EAAE,QAAqB;QACtE,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/B,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,GAAG,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,KAAK;QACH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY;QACV,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC5B,IAAI,UAAU,EAAE,EAAE,EAAE,CAAC;YACnB,UAAU,CAAC,EAAE,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,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\n//\n// `node:http2` and `node:zlib` are resolved on first use, not at import time.\n// framework.ts imports this module unconditionally (it has to - the HTTP/2\n// branch is chosen at construction), but the vast majority of apps never take\n// that branch. Loading node:http2 eagerly costs every app ~1 MB RSS on top of\n// http/https, and the zlib compressors another ~0.3 MB, for code they never\n// run. Builtins are always synchronously requirable on every supported Node,\n// so this needs no dynamic import and no engines bump.\nimport type {\n Http2Server,\n Http2SecureServer,\n ServerHttp2Stream,\n IncomingHttpHeaders,\n OutgoingHttpHeaders,\n} from 'http2';\nimport { createRequire } from 'module';\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\n// Builtins only, so the base is irrelevant; 'file:///' keeps this compiling\n// under the CJS transform Jest applies to the test suite (import.meta is a\n// syntax error there).\nconst requireBuiltin = createRequire('file:///');\n\nlet http2Mod: typeof import('http2') | undefined;\nfunction http2(): typeof import('http2') {\n return (http2Mod ??= requireBuiltin('http2') as typeof import('http2'));\n}\n\nlet gzip: ((buf: Buffer) => Promise<Buffer>) | undefined;\nlet deflate: ((buf: Buffer) => Promise<Buffer>) | undefined;\nfunction compressors() {\n if (!gzip) {\n const zlib = requireBuiltin('zlib') as typeof import('zlib');\n gzip = promisify(zlib.gzip) as (buf: Buffer) => Promise<Buffer>;\n deflate = promisify(zlib.deflate) as (buf: Buffer) => Promise<Buffer>;\n }\n return { gzip: gzip, deflate: deflate as (buf: Buffer) => Promise<Buffer> };\n}\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 = http2().createSecureServer(serverOptions);\n this.logger.info('HTTP/2 secure server created', 'ServerInit');\n } else {\n this.server = http2().createServer(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 compressors().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 compressors().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":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,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,4EAA4E;AAC5E,2EAA2E;AAC3E,uBAAuB;AACvB,MAAM,cAAc,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAEjD,IAAI,QAA4C,CAAC;AACjD,SAAS,KAAK;IACZ,OAAO,CAAC,QAAQ,KAAK,cAAc,CAAC,OAAO,CAA2B,CAAC,CAAC;AAC1E,CAAC;AAED,IAAI,IAAoD,CAAC;AACzD,IAAI,OAAuD,CAAC;AAC5D,SAAS,WAAW;IAClB,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAA0B,CAAC;QAC7D,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAqC,CAAC;QAChE,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAqC,CAAC;IACxE,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAA2C,EA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,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\n//\n// `node:http2` and `node:zlib` are resolved on first use, not at import time.\n// framework.ts imports this module unconditionally (it has to - the HTTP/2\n// branch is chosen at construction), but the vast majority of apps never take\n// that branch. Loading node:http2 eagerly costs every app ~1 MB RSS on top of\n// http/https, and the zlib compressors another ~0.3 MB, for code they never\n// run. Builtins are always synchronously requirable on every supported Node,\n// so this needs no dynamic import and no engines bump.\nimport type {\n Http2Server,\n Http2SecureServer,\n ServerHttp2Stream,\n IncomingHttpHeaders,\n OutgoingHttpHeaders,\n} from 'http2';\nimport { createRequire } from 'module';\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\n// Builtins only, so the base is irrelevant; 'file:///' keeps this compiling\n// under the CJS transform Jest applies to the test suite (import.meta is a\n// syntax error there).\nconst requireBuiltin = createRequire('file:///');\n\nlet http2Mod: typeof import('http2') | undefined;\nfunction http2(): typeof import('http2') {\n return (http2Mod ??= requireBuiltin('http2') as typeof import('http2'));\n}\n\nlet gzip: ((buf: Buffer) => Promise<Buffer>) | undefined;\nlet deflate: ((buf: Buffer) => Promise<Buffer>) | undefined;\nfunction compressors() {\n if (!gzip) {\n const zlib = requireBuiltin('zlib') as typeof import('zlib');\n gzip = promisify(zlib.gzip) as (buf: Buffer) => Promise<Buffer>;\n deflate = promisify(zlib.deflate) as (buf: Buffer) => Promise<Buffer>;\n }\n return { gzip: gzip, deflate: deflate as (buf: Buffer) => Promise<Buffer> };\n}\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 = http2().createSecureServer(serverOptions);\n this.logger.info('HTTP/2 secure server created', 'ServerInit');\n } else {\n this.server = http2().createServer(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 // A request hook may answer the request itself (rate limiting, auth\n // rejection). Registration of the response hooks above still stands.\n if (httpRes.headersSent) return;\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 compressors().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 compressors().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"]}
|
|
@@ -268,6 +268,7 @@ export declare class MoroEngineServer {
|
|
|
268
268
|
private handleDispatchError;
|
|
269
269
|
private parseBody;
|
|
270
270
|
private executeMiddleware;
|
|
271
|
+
private dispatchMiddleware;
|
|
271
272
|
use(middleware: Middleware): void;
|
|
272
273
|
setRequestTracking(enabled: boolean): void;
|
|
273
274
|
setHookManager(hookManager: any): void;
|
|
@@ -80,6 +80,12 @@ const SENDFILE_BUFFER_LIMIT = 1024 * 1024;
|
|
|
80
80
|
// the response has no user-set headers, so no header object or flat array is
|
|
81
81
|
// allocated. The engine only reads it; never mutate.
|
|
82
82
|
const JSON_HEADER_PAIR = ['content-type', 'application/json'];
|
|
83
|
+
// Content-Type sniff for send(): does the body start with '{' or '[' after
|
|
84
|
+
// optional leading whitespace? Regex `\s` matches exactly the set trimStart()
|
|
85
|
+
// strips, and the match stops at the first non-space character, so this costs
|
|
86
|
+
// O(leading whitespace) and allocates nothing - trimStart() copied the entire
|
|
87
|
+
// body just to read one character.
|
|
88
|
+
const JSON_BODY_START = /^\s*[{[]/;
|
|
83
89
|
/**
|
|
84
90
|
* Prototype-based request object for the engine adapter.
|
|
85
91
|
*
|
|
@@ -705,11 +711,9 @@ export class EngineResponse extends LazyEventEmitter {
|
|
|
705
711
|
// Buffers, text/plain otherwise.
|
|
706
712
|
if (!('content-type' in this.responseHeaders)) {
|
|
707
713
|
if (typeof data === 'string') {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
? 'application/json; charset=utf-8'
|
|
712
|
-
: 'text/plain; charset=utf-8';
|
|
714
|
+
this.responseHeaders['content-type'] = JSON_BODY_START.test(data)
|
|
715
|
+
? 'application/json; charset=utf-8'
|
|
716
|
+
: 'text/plain; charset=utf-8';
|
|
713
717
|
}
|
|
714
718
|
else {
|
|
715
719
|
this.responseHeaders['content-type'] = 'application/octet-stream';
|
|
@@ -1812,9 +1816,17 @@ export class MoroEngineServer {
|
|
|
1812
1816
|
void Promise.resolve(hookManager.execute('response', { request: httpReq, response: httpRes })).catch((error) => this.logger?.error?.(`Response hook error: ${error?.message || error}`, 'Hooks'));
|
|
1813
1817
|
});
|
|
1814
1818
|
}
|
|
1815
|
-
//
|
|
1819
|
+
// A request hook may answer the request itself (rate limiting, auth
|
|
1820
|
+
// rejection). Registration of the response hooks above still stands.
|
|
1821
|
+
if (httpRes.headersSent)
|
|
1822
|
+
return;
|
|
1823
|
+
// Execute global middleware chain. executeMiddleware returns undefined
|
|
1824
|
+
// when the whole chain completed synchronously, so a sync chain costs
|
|
1825
|
+
// zero promise allocations.
|
|
1816
1826
|
if (this.globalMiddleware.length > 0) {
|
|
1817
|
-
|
|
1827
|
+
const mwResult = this.executeMiddleware(this.globalMiddleware, httpReq, httpRes);
|
|
1828
|
+
if (mwResult)
|
|
1829
|
+
await mwResult;
|
|
1818
1830
|
if (httpRes.headersSent)
|
|
1819
1831
|
return;
|
|
1820
1832
|
}
|
|
@@ -1953,42 +1965,103 @@ export class MoroEngineServer {
|
|
|
1953
1965
|
throw error;
|
|
1954
1966
|
}
|
|
1955
1967
|
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1968
|
+
// Middleware execution with Express-compatible error propagation.
|
|
1969
|
+
// Supports: 3-arg (req, res, next), 4-arg (err, req, res, next) error middlewares,
|
|
1970
|
+
// and next(err) to skip forward to the next error middleware.
|
|
1971
|
+
//
|
|
1972
|
+
// Sync-aware dispatch (mirrors MoroHttpServer.executeMiddleware): middleware
|
|
1973
|
+
// that calls next() synchronously (or throws synchronously) advances the
|
|
1974
|
+
// chain in a plain loop with ZERO promise allocations. A promise is only
|
|
1975
|
+
// created when a middleware actually completes asynchronously. Returns
|
|
1976
|
+
// undefined when the whole chain ran synchronously, so the caller can skip
|
|
1977
|
+
// its await - one sync global middleware used to cost a promise, a closure
|
|
1978
|
+
// and an async-context suspension on every single request.
|
|
1979
|
+
executeMiddleware(middleware, req, res) {
|
|
1980
|
+
return this.dispatchMiddleware(middleware, req, res, 0, undefined);
|
|
1981
|
+
}
|
|
1982
|
+
dispatchMiddleware(middleware, req, res, startIndex, initialError) {
|
|
1983
|
+
const len = middleware.length;
|
|
1984
|
+
let activeError = initialError;
|
|
1985
|
+
let i = startIndex;
|
|
1986
|
+
while (i < len) {
|
|
1964
1987
|
if (res.headersSent)
|
|
1965
|
-
|
|
1988
|
+
return;
|
|
1989
|
+
const mw = middleware[i];
|
|
1990
|
+
i++;
|
|
1966
1991
|
const isErrorHandler = mw.length >= 4;
|
|
1967
|
-
|
|
1992
|
+
// Non-error middleware is skipped while an error is active; error middleware
|
|
1993
|
+
// is skipped while no error is active. Matches Express semantics.
|
|
1994
|
+
if (activeError !== undefined && !isErrorHandler)
|
|
1968
1995
|
continue;
|
|
1969
|
-
if (
|
|
1996
|
+
if (activeError === undefined && isErrorHandler)
|
|
1970
1997
|
continue;
|
|
1998
|
+
let settled = false;
|
|
1999
|
+
let settledError = undefined;
|
|
2000
|
+
let asyncResolve;
|
|
2001
|
+
const next = (err) => {
|
|
2002
|
+
if (settled)
|
|
2003
|
+
return;
|
|
2004
|
+
settled = true;
|
|
2005
|
+
settledError = err;
|
|
2006
|
+
if (asyncResolve)
|
|
2007
|
+
asyncResolve(err);
|
|
2008
|
+
};
|
|
2009
|
+
let result;
|
|
1971
2010
|
try {
|
|
1972
|
-
|
|
1973
|
-
const next = (err) => (err ? reject(err) : resolve());
|
|
1974
|
-
try {
|
|
1975
|
-
const result = error ? mw(error, req, res, next) : mw(req, res, next);
|
|
1976
|
-
if (result && typeof result.then === 'function') {
|
|
1977
|
-
result.then(() => resolve(), reject);
|
|
1978
|
-
}
|
|
1979
|
-
}
|
|
1980
|
-
catch (e) {
|
|
1981
|
-
reject(e);
|
|
1982
|
-
}
|
|
1983
|
-
});
|
|
1984
|
-
error = null; // handler (error or normal) completed cleanly
|
|
2011
|
+
result = isErrorHandler ? mw(activeError, req, res, next) : mw(req, res, next);
|
|
1985
2012
|
}
|
|
1986
|
-
catch (
|
|
1987
|
-
|
|
2013
|
+
catch (err) {
|
|
2014
|
+
if (!settled) {
|
|
2015
|
+
settled = true;
|
|
2016
|
+
settledError = err;
|
|
2017
|
+
}
|
|
1988
2018
|
}
|
|
2019
|
+
const isThenable = result && typeof result.then === 'function';
|
|
2020
|
+
if (settled) {
|
|
2021
|
+
// Completed synchronously (next() called sync, or threw sync). A still
|
|
2022
|
+
// pending returned promise no longer gates the chain once next() has
|
|
2023
|
+
// been called; swallow late rejections so they never go unhandled.
|
|
2024
|
+
if (isThenable) {
|
|
2025
|
+
result.then(undefined, () => { });
|
|
2026
|
+
}
|
|
2027
|
+
activeError = settledError;
|
|
2028
|
+
continue;
|
|
2029
|
+
}
|
|
2030
|
+
if (!isThenable && res.headersSent) {
|
|
2031
|
+
// Terminal middleware (Express style): it answered the request and
|
|
2032
|
+
// deliberately never calls next(). The chain is finished - skip
|
|
2033
|
+
// allocating a promise that nothing would ever settle (the response was
|
|
2034
|
+
// already sent, so this only ever produced immediate garbage).
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
if (!isThenable) {
|
|
2038
|
+
// Sync-looking middleware that neither called next() nor returned a
|
|
2039
|
+
// promise: it will call next() later (e.g. from an event callback).
|
|
2040
|
+
// Fall back to a promise for the remainder of the chain.
|
|
2041
|
+
const resumeIndex = i;
|
|
2042
|
+
return new Promise(resolve => {
|
|
2043
|
+
asyncResolve = resolve;
|
|
2044
|
+
}).then(err => this.dispatchMiddleware(middleware, req, res, resumeIndex, err));
|
|
2045
|
+
}
|
|
2046
|
+
// Async middleware: completion is next() OR promise settle, whichever
|
|
2047
|
+
// happens first (same semantics as the previous implementation).
|
|
2048
|
+
const resumeIndex = i;
|
|
2049
|
+
return new Promise(resolve => {
|
|
2050
|
+
asyncResolve = resolve;
|
|
2051
|
+
result.then(() => {
|
|
2052
|
+
if (!settled)
|
|
2053
|
+
next();
|
|
2054
|
+
}, (err) => {
|
|
2055
|
+
if (!settled)
|
|
2056
|
+
next(err);
|
|
2057
|
+
});
|
|
2058
|
+
}).then(err => this.dispatchMiddleware(middleware, req, res, resumeIndex, err));
|
|
2059
|
+
}
|
|
2060
|
+
// If an error is still unhandled after the chain, re-throw so the top-level
|
|
2061
|
+
// catch in handleRequest can invoke the registered errorHandler / default 500.
|
|
2062
|
+
if (activeError !== undefined) {
|
|
2063
|
+
throw activeError;
|
|
1989
2064
|
}
|
|
1990
|
-
if (error)
|
|
1991
|
-
throw error;
|
|
1992
2065
|
}
|
|
1993
2066
|
// Public API - matches MoroHttpServer/UWebSocketsHttpServer interface
|
|
1994
2067
|
use(middleware) {
|