@morojs/moro 1.8.6 → 1.8.8
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.d.ts +5 -3
- package/dist/core/http/http-server.js +42 -11
- package/dist/core/http/http-server.js.map +1 -1
- package/dist/core/http/http2-server.d.ts +1 -1
- package/dist/core/http/http2-server.js +27 -9
- package/dist/core/http/http2-server.js.map +1 -1
- package/dist/core/http/moro-engine-server.d.ts +24 -4
- package/dist/core/http/moro-engine-server.js +198 -42
- package/dist/core/http/moro-engine-server.js.map +1 -1
- package/dist/core/http/uws-http-server.js +4 -0
- 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/pooling/object-pool-manager.js +14 -20
- package/dist/core/pooling/object-pool-manager.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/radix-tree.d.ts +1 -0
- package/dist/core/routing/radix-tree.js +6 -1
- package/dist/core/routing/radix-tree.js.map +1 -1
- package/dist/core/routing/unified-router.js +28 -25
- package/dist/core/routing/unified-router.js.map +1 -1
- package/dist/core/utilities/hooks.d.ts +2 -0
- package/dist/core/utilities/hooks.js +28 -2
- package/dist/core/utilities/hooks.js.map +1 -1
- package/dist/index.d.ts +2 -6
- package/dist/moro.js +12 -0
- package/dist/moro.js.map +1 -1
- package/dist/types/http.d.ts +3 -0
- package/dist/types/http.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moro-engine-server.js","sourceRoot":"","sources":["../../../src/core/http/moro-engine-server.ts"],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E,EAAE,CAAC,CAAC;YACP,6DAA6D;YAC5D,IAAY,CAAC,KAAK,EAAE,EAAE,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,OAAO,EAAE;gBACjD,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;YACH,IAAI,QAAQ;gBAAE,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;IAED,SAAS;QACP,2EAA2E;QAC3E,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YAAY;QACV,mCAAmC;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC","sourcesContent":["// Moro Engine HTTP Server Implementation (@morojs/engine)\n//\n// One of the three HTTP backends, kept deliberately separate from the others:\n// - MoroHttpServer (http-server.ts) -> Node's http module\n// - UWebSocketsHttpServer (uws-http-server.ts) -> uWebSockets.js (opt-in)\n// - MoroEngineServer (this file) -> @morojs/engine, Moro's own\n// from-scratch native engine\n//\n// Bridges the Moro-shaped native engine API (one JS crossing per request in,\n// one out - see the engine repo's docs/API.md) with Moro's HTTP abstractions.\n// Unlike the uWS adapter there is no materialize() hazard: every per-request\n// fetcher (getHeaders/getQuery/getBody/...) returns a stable snapshot, and the\n// body is already complete when onRequest fires. Keep-alive, Content-Length,\n// Date, chunked encoding, HEAD body suppression and native 413/400 are all\n// engine concerns - this adapter never sees them. No dependency on the uWS\n// adapter: shared helpers live in ./utils.\n\nimport { randomUUID } from 'crypto';\nimport { createFrameworkLogger } from '../logger/index.js';\nimport { HttpRequest, HttpResponse, HttpHandler, Middleware } from '../../types/http.js';\nimport {\n loadNativeEngine,\n getNativeEngineLoadErrors,\n type EngineCapabilities,\n} from '../utilities/package-utils.js';\nimport {\n parseMultipart as parseMultipartBuffer,\n type MultipartLimits,\n} from './utils/multipart-parser.js';\nimport type { HttpRuntimeLimits } from './utils/size.js';\nimport type { Http2ServerOptions } from './http2-server.js';\nimport {\n resolveCompressionSettings,\n compressBuffer,\n isCompressible,\n negotiateEncoding,\n type CompressionSettings,\n} from './utils/compression.js';\nimport { LazyEventEmitter } from './utils/lazy-event-emitter.js';\nimport { parseRawQueryString as parseUwsQueryString } from './utils/query-parser.js';\nimport { PathMatcher } from '../routing/path-matcher.js';\n\n/** Engine method table - onRequest's methodIdx indexes into this */\nconst METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS', 'OTHER'] as const;\n\n// Pre-cached status strings for common codes (sendStatus bodies; the engine\n// derives the wire reason phrase from the numeric status itself)\nconst STATUS_STRINGS = new Map([\n [200, '200 OK'],\n [201, '201 Created'],\n [204, '204 No Content'],\n [301, '301 Moved Permanently'],\n [302, '302 Found'],\n [304, '304 Not Modified'],\n [400, '400 Bad Request'],\n [401, '401 Unauthorized'],\n [403, '403 Forbidden'],\n [404, '404 Not Found'],\n [500, '500 Internal Server Error'],\n [502, '502 Bad Gateway'],\n [503, '503 Service Unavailable'],\n]);\n\n// Same table as MoroHttpServer.getMimeType - kept sync here so attachment()\n// stays chainable without a fire-and-forget promise\nconst MIME_TYPES: Record<string, string> = {\n '.html': 'text/html',\n '.css': 'text/css',\n '.js': 'application/javascript',\n '.json': 'application/json',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n '.pdf': 'application/pdf',\n '.txt': 'text/plain',\n '.xml': 'application/xml',\n};\n\nfunction mimeTypeFor(ext: string): string {\n return MIME_TYPES[ext.toLowerCase()] || 'application/octet-stream';\n}\n\nfunction addCharsetIfNeeded(mimeType: string): string {\n if (\n mimeType.startsWith('text/') ||\n mimeType.startsWith('application/json') ||\n mimeType.startsWith('application/javascript') ||\n mimeType.startsWith('application/xml') ||\n mimeType.startsWith('image/svg+xml')\n ) {\n if (!mimeType.includes('charset')) {\n return `${mimeType}; charset=utf-8`;\n }\n }\n return mimeType;\n}\n\n// Files up to this size are sent with a single respond(); larger ones stream\n// through writeHead/write/end with backpressure respected via 'drain'\nconst SENDFILE_BUFFER_LIMIT = 1024 * 1024;\n\n/**\n * Prototype-based request object for the engine adapter.\n *\n * Headers/query/cookies/ip/requestId are lazy: a synchronous handler that\n * never reads them pays nothing (no native crossing, no UUID). Every fetcher\n * returns a stable snapshot and reqIds are safe no-ops after the response\n * terminates, so - unlike the uWS adapter - there is no validity window.\n */\nexport class EngineRequest extends LazyEventEmitter {\n method: string;\n path: string;\n params: Record<string, string> = {};\n body: any = null;\n\n _server: MoroEngineServer;\n _reqId: number;\n _url: string | undefined = undefined;\n _queryString: string | undefined = undefined;\n _query: Record<string, string> | undefined = undefined;\n _headers: Record<string, string> | undefined = undefined;\n _cookies: Record<string, string> | undefined = undefined;\n _context: Record<string, any> | undefined = undefined;\n _requestId: string | undefined = undefined;\n _ip: string | undefined = undefined;\n _socket: any = undefined;\n\n constructor(server: MoroEngineServer, reqId: number, method: string, path: string) {\n super();\n this._server = server;\n this._reqId = reqId;\n this.method = method;\n this.path = path;\n }\n\n /** Engine snapshots are stable - nothing to detach. No-op kept for\n * interface parity with UwsRequest so shared dispatch code can call it. */\n materialize(): void {}\n\n private _rawQueryString(): string {\n let qs = this._queryString;\n if (qs === undefined) {\n // Safe no-op (undefined) after the response terminates - coerce to ''\n qs = this._server._engine.getQuery(this._reqId) ?? '';\n this._queryString = qs as string;\n }\n return qs as string;\n }\n\n get url(): string {\n let u = this._url;\n if (u === undefined) {\n const qs = this._rawQueryString();\n u = qs ? `${this.path}?${qs}` : this.path;\n this._url = u;\n }\n return u;\n }\n set url(value: string) {\n this._url = value;\n }\n\n get query(): Record<string, string> {\n let q = this._query;\n if (q === undefined) {\n const qs = this._rawQueryString();\n q = qs ? parseUwsQueryString(qs) : {};\n this._query = q;\n }\n return q;\n }\n set query(value: Record<string, string>) {\n this._query = value;\n }\n\n get headers(): Record<string, string> {\n let h = this._headers;\n if (h === undefined) {\n h = {};\n // One crossing: flat [k1,v1,k2,v2,...] with keys already lowercased.\n // Duplicate header lines are joined like Node's IncomingMessage ('; '\n // for cookie, ', ' otherwise) - last-wins would let a client hide\n // earlier X-Forwarded-For entries from IP-based middleware.\n const flat: string[] | undefined = this._server._engine.getHeaders(this._reqId);\n if (flat) {\n for (let i = 0; i + 1 < flat.length; i += 2) {\n const key = flat[i];\n const val = flat[i + 1];\n if (key === undefined || val === undefined) continue;\n const existing = h[key];\n if (existing === undefined) {\n h[key] = val;\n } else {\n h[key] = existing + (key === 'cookie' ? '; ' : ', ') + val;\n }\n }\n }\n this._headers = h;\n }\n return h;\n }\n set headers(value: Record<string, string>) {\n this._headers = value;\n }\n\n get cookies(): Record<string, string> {\n let c = this._cookies;\n if (c === undefined) {\n c = {};\n const header = this.headers.cookie;\n if (header) {\n const parts = header.split(';');\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if (part === undefined) continue;\n const eq = part.indexOf('=');\n if (eq > 0) {\n const name = part.substring(0, eq).trim();\n const value = part.substring(eq + 1);\n if (name && value) {\n try {\n c[name] = decodeURIComponent(value);\n } catch {\n c[name] = value;\n }\n }\n }\n }\n }\n this._cookies = c;\n }\n return c;\n }\n set cookies(value: Record<string, string>) {\n this._cookies = value;\n }\n\n get context(): Record<string, any> {\n let ctx = this._context;\n if (ctx === undefined) {\n ctx = {};\n this._context = ctx;\n }\n return ctx;\n }\n set context(value: Record<string, any>) {\n this._context = value;\n }\n\n get requestId(): string {\n let id = this._requestId;\n if (id === undefined) {\n const server = this._server;\n id = server && (server as any).requestTrackingEnabled ? randomUUID() : '';\n this._requestId = id;\n }\n return id;\n }\n set requestId(value: string) {\n this._requestId = value;\n }\n\n get ip(): string {\n let ip = this._ip;\n if (ip === undefined) {\n ip = this._server._engine.getRemoteAddress(this._reqId) ?? '';\n this._ip = ip as string;\n }\n return ip as string;\n }\n set ip(value: string) {\n this._ip = value;\n }\n\n // Minimal net.Socket-shaped shim. `encrypted` reflects whether the engine\n // is terminating TLS for this server (engine >= 1.2.0); when it isn't and\n // TLS is proxy-terminated, middleware should read `x-forwarded-proto`. This\n // exists so code written against Node's IncomingMessage (req.socket.encrypted,\n // the CSRF middleware; req.connection.remoteAddress, rate-limiters) doesn't\n // throw on the engine transport. `connection` is the legacy alias for `socket`.\n get socket(): any {\n let s = this._socket;\n if (s === undefined) {\n const getIp = () => this.ip; // arrow captures this lexically (no this-alias)\n const encrypted = Boolean((this._server as any)?.isSsl);\n s = {\n get remoteAddress() {\n return getIp() || undefined;\n },\n remotePort: undefined,\n encrypted,\n destroyed: false,\n };\n this._socket = s;\n }\n return s;\n }\n set socket(value: any) {\n this._socket = value;\n }\n\n get connection(): any {\n return this.socket;\n }\n set connection(value: any) {\n this._socket = value;\n }\n\n // ==== Express-compatible request helpers (parity with the uWS adapter) ====\n\n get hostname(): string {\n const host = this.headers.host || '';\n return host ? (host.split(':')[0] ?? '') : '';\n }\n\n get protocol(): string {\n const forwardedProto = this.headers['x-forwarded-proto'];\n if (forwardedProto) return (forwardedProto.split(',')[0] ?? '').trim();\n return this._server && (this._server as any).isSsl ? 'https' : 'http';\n }\n\n get secure(): boolean {\n return this.protocol === 'https';\n }\n\n get xhr(): boolean {\n const xrw = this.headers['x-requested-with'];\n return !!xrw && xrw.toLowerCase() === 'xmlhttprequest';\n }\n\n get originalUrl(): string {\n return this.url;\n }\n\n get ips(): string[] {\n const forwardedFor = this.headers['x-forwarded-for'];\n return forwardedFor\n ? forwardedFor\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n : [];\n }\n\n get subdomains(): string[] {\n const hostnameParts = this.hostname.split('.');\n return hostnameParts.length > 2 ? hostnameParts.slice(0, -2).reverse() : [];\n }\n\n get(name: string): string | undefined {\n const lower = name.toLowerCase();\n if (lower === 'referer' || lower === 'referrer') {\n return this.headers.referer || (this.headers as any).referrer;\n }\n return this.headers[lower];\n }\n\n header(name: string): string | undefined {\n return this.get(name);\n }\n\n is(type: string): boolean {\n const ct = this.headers['content-type'] || '';\n if (!ct) return false;\n const mime = (ct.split(';')[0] ?? '').trim().toLowerCase();\n const t = type.toLowerCase();\n if (t.indexOf('/') === -1) {\n return mime.endsWith(`/${t}`) || mime.endsWith(`+${t}`);\n }\n if (t.endsWith('/*')) {\n return mime.startsWith(t.slice(0, -1));\n }\n return mime === t;\n }\n\n accepts(types?: string | string[]): string | false {\n const accept = this.headers.accept || '*/*';\n if (!types) return accept;\n const wanted = Array.isArray(types) ? types : [types];\n if (accept === '*/*' || accept === '') return wanted[0] || false;\n const acceptTypes = accept.split(',').map(s => (s.split(';')[0] ?? '').trim().toLowerCase());\n for (const w of wanted) {\n const wl = w.toLowerCase();\n const wMime = wl.indexOf('/') === -1 ? `application/${wl}` : wl;\n for (const at of acceptTypes) {\n if (at === '*/*') return w;\n if (at === wMime) return w;\n if (at.endsWith('/*') && wMime.startsWith(at.slice(0, -1))) return w;\n }\n }\n return false;\n }\n\n acceptsLanguages(langs?: string | string[]): string | false {\n const acceptLang = this.headers['accept-language'] || '';\n if (!langs) return acceptLang || false;\n const wanted = Array.isArray(langs) ? langs : [langs];\n if (!acceptLang) return wanted[0] || false;\n const accepted = acceptLang\n .split(',')\n .map(s => {\n const parts = s.trim().split(';');\n const tag = (parts[0] ?? '').toLowerCase();\n const qPart = parts.find(p => p.trim().startsWith('q='));\n const q = qPart ? parseFloat(qPart.trim().slice(2)) : 1;\n return { tag, q: isNaN(q) ? 0 : q };\n })\n .filter(a => a.q > 0)\n .sort((a, b) => b.q - a.q);\n for (const { tag } of accepted) {\n for (const w of wanted) {\n const wl = w.toLowerCase();\n if (tag === '*' || tag === wl || tag.split('-')[0] === wl.split('-')[0]) return w;\n }\n }\n return false;\n }\n}\n\n/**\n * Prototype-based response object for the engine adapter. Same\n * MoroResponseMethods surface as the uWS adapter's ResponsePrototype.\n *\n * Terminal writes (json/send/end/redirect) go out as ONE respond() call -\n * status + headers + body in a single native crossing. Streaming responses\n * (writeHead/write/end) map to the engine's streaming API; the engine's\n * onWritable backpressure signal surfaces as the 'drain' event.\n */\nexport class EngineResponse extends LazyEventEmitter {\n public headersSent = false;\n public statusCode = 200;\n public responseHeaders: Record<string, string | string[]> = {};\n public locals: Record<string, any> = {};\n // The EngineRequest wrapper, linked by the server so lifecycle events reach\n // req.on('close') listeners (SSE cleanup, monitors)\n public _moroReq: any = null;\n\n private _server: MoroEngineServer;\n private _engine: any;\n private _reqId: number;\n private _logger: any;\n // Terminal-write latch: headersSent means \"head flushed\" (true mid-stream\n // after writeHead/write), _ended means the body is complete\n private _ended = false;\n private _aborted = false;\n\n constructor(server: MoroEngineServer, reqId: number, logger: any) {\n super();\n this._server = server;\n this._engine = server._engine;\n this._reqId = reqId;\n this._logger = logger;\n }\n\n get writableEnded() {\n return this._ended;\n }\n\n get writableFinished() {\n return this._ended;\n }\n\n get finished() {\n return this._ended;\n }\n\n get aborted() {\n return this._aborted;\n }\n\n // Node ServerResponse lifecycle: 'finish' then 'close' after the terminal\n // write; the request wrapper's 'close' fires too (IncomingMessage parity).\n // Also releases the reqId from the server's in-flight map.\n private _emitDone() {\n this._ended = true;\n this._server._complete(this._reqId);\n if (this._events) {\n this.emit('finish');\n this.emit('close');\n }\n const req = this._moroReq;\n if (req && req._events) req.emit('close');\n }\n\n // Client aborted: 'close' without 'finish' (Node semantics), plus\n // 'aborted'/'close' on the request wrapper. All later engine calls with\n // this reqId are safe no-ops, but the guards below skip them anyway.\n _handleAbort() {\n if (this._ended) return;\n this._ended = true;\n this._aborted = true;\n if (this._events) this.emit('close');\n const req = this._moroReq;\n if (req && req._events) {\n req.emit('aborted');\n req.emit('close');\n }\n }\n\n // Backpressure: the engine's onWritable relayed as the 'drain' event that\n // pipe() and manual streaming loops wait on\n _handleWritable() {\n this.emit('drain');\n }\n\n // Build the engine's flat [k1,v1,k2,v2,...] header array from headers\n // actually set. Multi-value headers (set-cookie) become separate pairs so\n // each goes out as its own header line.\n private _headersFlat(): string[] | null {\n const headers = this.responseHeaders;\n let flat: string[] | null = null;\n // Performance: for...in is the fastest way to iterate response headers\n for (const key in headers) {\n const value = headers[key];\n if (flat === null) flat = [];\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) flat.push(key, String(value[i]));\n } else {\n flat.push(key, String(value));\n }\n }\n return flat;\n }\n\n status(code: number) {\n this.statusCode = code;\n return this;\n }\n\n setHeader(name: string, value: string | string[]) {\n // Cache toLowerCase result to avoid repeated calls\n const lowerName = name.toLowerCase();\n this.responseHeaders[lowerName] = value;\n return this;\n }\n\n getHeader(name: string) {\n const lowerName = name.toLowerCase();\n return this.responseHeaders[lowerName];\n }\n\n removeHeader(name: string) {\n const lowerName = name.toLowerCase();\n if (lowerName in this.responseHeaders) {\n delete this.responseHeaders[lowerName];\n }\n return this;\n }\n\n json(data: any) {\n if (this.headersSent || this._ended) return;\n\n // Fast-path JSON serialization for common API patterns\n let body: string;\n\n // The interpolated fast path is only valid when `success` is a real boolean\n // (a string/number would produce invalid JSON like {\"success\":yes,...});\n // otherwise fall through to JSON.stringify.\n if (data && typeof data === 'object' && typeof data.success === 'boolean') {\n let keyCount = 0;\n let hasData = false;\n let hasError = false;\n let hasTotal = false;\n\n for (const key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n keyCount++;\n if (key === 'data') hasData = true;\n else if (key === 'error') hasError = true;\n else if (key === 'total') hasTotal = true;\n }\n }\n\n // JSON.stringify(undefined) yields the literal token \"undefined\"; guard the\n // interpolated branches so an explicit `data: undefined` doesn't corrupt\n // the body (fall through to JSON.stringify, which omits the key instead).\n if (\n keyCount === 3 &&\n hasData &&\n hasError &&\n data.data !== undefined &&\n data.error !== undefined\n ) {\n body = `{\"success\":${data.success},\"data\":${JSON.stringify(data.data)},\"error\":${JSON.stringify(data.error)}}`;\n } else if (\n keyCount === 3 &&\n hasData &&\n hasTotal &&\n data.data !== undefined &&\n typeof data.total === 'number'\n ) {\n body = `{\"success\":${data.success},\"data\":${JSON.stringify(data.data)},\"total\":${data.total}}`;\n } else if (keyCount === 2 && hasData && data.data !== undefined) {\n body = `{\"success\":${data.success},\"data\":${JSON.stringify(data.data)}}`;\n } else if (keyCount === 2 && hasError && data.error !== undefined) {\n body = `{\"success\":${data.success},\"error\":${JSON.stringify(data.error)}}`;\n } else {\n body = JSON.stringify(data);\n }\n } else {\n body = JSON.stringify(data);\n }\n\n if (!('content-type' in this.responseHeaders)) {\n this.responseHeaders['content-type'] = 'application/json';\n }\n\n try {\n this._respondMaybeCompressed(body, 'application/json');\n } catch (err) {\n this._failSafe('Failed to send JSON response', err);\n }\n }\n\n // Buffered-response compression parity with the Node path. Terminal helper:\n // respond() with `body`, compressing first when enabled + compressible +\n // over threshold + the client accepts an encoding. Keeps the synchronous\n // fast path (zero extra work) whenever compression can't apply, so the\n // default (compression off) pays nothing.\n private _respondMaybeCompressed(body: string | Buffer, contentType?: string): void {\n const s = this._server._compression;\n // HOT PATH: compression is off by default - bail before ANY per-response\n // work (byteLength scans the string; header reads allocate nothing but\n // still cost). The default config must pay zero for this feature.\n if (!s.enabled) {\n this._engine.respond(this._reqId, this.statusCode, this._headersFlat(), body);\n this.headersSent = true;\n this._emitDone();\n return;\n }\n const bytes = typeof body === 'string' ? Buffer.byteLength(body) : body.length;\n const alreadyEncoded = 'content-encoding' in this.responseHeaders;\n const ctHeader = this.responseHeaders['content-type'];\n const ct = contentType ?? (Array.isArray(ctHeader) ? ctHeader[0] : ctHeader);\n if (\n alreadyEncoded ||\n bytes < s.threshold ||\n !isCompressible(ct) ||\n this.statusCode === 204 ||\n this.statusCode === 304\n ) {\n this._engine.respond(this._reqId, this.statusCode, this._headersFlat(), body);\n this.headersSent = true;\n this._emitDone();\n return;\n }\n\n const accept = this._engine.getHeader(this._reqId, 'accept-encoding') as string | undefined;\n const encoding = negotiateEncoding(accept, s.encodings);\n if (!encoding) {\n this._engine.respond(this._reqId, this.statusCode, this._headersFlat(), body);\n this.headersSent = true;\n this._emitDone();\n return;\n }\n\n // Async path: compress, then respond (guarding against an abort that\n // raced the await - the reqId would be invalid).\n void compressBuffer(body, encoding, s.level)\n .then(compressed => {\n if (this._ended || this._engine.isAborted(this._reqId)) return;\n this.responseHeaders['content-encoding'] = encoding;\n const vary = this.responseHeaders['vary'];\n this.responseHeaders['vary'] = vary ? `${vary}, Accept-Encoding` : 'Accept-Encoding';\n this._engine.respond(this._reqId, this.statusCode, this._headersFlat(), compressed);\n this.headersSent = true;\n this._emitDone();\n })\n .catch(err => this._failSafe('Failed to compress response', err));\n }\n\n // A response-send failure must never leave the request hanging open (the\n // sweep exempts active requests, so nothing else would ever close it):\n // attempt a plain 500, then release the wrapper either way.\n private _failSafe(context: string, err: unknown) {\n this._logger.error(\n `${context}: ${err instanceof Error ? err.message : String(err)}`,\n 'ResponseError'\n );\n if (!this._ended) {\n try {\n this._engine.respond(\n this._reqId,\n 500,\n null,\n '{\"success\":false,\"error\":\"Internal server error\"}'\n );\n this.headersSent = true;\n } catch {\n // reqId already gone (aborted/finished) - nothing to send\n }\n this._emitDone();\n }\n }\n\n send(data: string | Buffer) {\n if (this.headersSent || this._ended) return;\n\n // Default a Content-Type to match the Node server (parity for the now-\n // default engine path): JSON for JSON-looking strings, octet-stream for\n // Buffers, text/plain otherwise.\n if (!('content-type' in this.responseHeaders)) {\n if (typeof data === 'string') {\n const t = data.trimStart();\n this.responseHeaders['content-type'] =\n t.startsWith('{') || t.startsWith('[')\n ? 'application/json; charset=utf-8'\n : 'text/plain; charset=utf-8';\n } else {\n this.responseHeaders['content-type'] = 'application/octet-stream';\n }\n }\n\n try {\n // Buffers pass through binary-safe (the engine accepts Uint8Array).\n // Compression applies only to compressible content types (isCompressible\n // excludes octet-stream), so binary sends stay on the sync fast path.\n this._respondMaybeCompressed(data);\n // headersSent/_emitDone handled inside the helper.\n } catch (err) {\n this._failSafe('Failed to send response', err);\n }\n }\n\n // Flush status + headers without ending the response (Node streaming\n // entry point - SSE and manual chunked responses start here). Supports\n // both (code, headers) and (code, statusMessage, headers) signatures;\n // the engine derives the reason phrase from the status code, so a custom\n // message cannot be sent on the wire and is ignored.\n writeHead(statusCode: number, reasonOrHeaders?: any, maybeHeaders?: any) {\n if (this.headersSent || this._ended) return this;\n\n this.statusCode = statusCode;\n const headers =\n reasonOrHeaders && typeof reasonOrHeaders === 'object' ? reasonOrHeaders : maybeHeaders;\n if (headers) {\n for (const key of Object.keys(headers)) {\n this.setHeader(key, headers[key]);\n }\n }\n\n try {\n this._engine.writeHead(this._reqId, statusCode, this._headersFlat());\n this.headersSent = true;\n } catch {\n this._logger.error('Failed to write response head', 'ResponseError');\n }\n\n return this;\n }\n\n // Stream a body chunk, flushing the head first if needed. Returns the\n // engine's backpressure signal like Node's Writable.write; 'drain' fires\n // (via onWritable) when the socket can accept more.\n write(chunk: any, encoding?: any, callback?: any): boolean {\n if (typeof encoding === 'function') {\n callback = encoding;\n encoding = undefined;\n }\n if (this._ended) return false;\n\n let ok = true;\n try {\n if (!this.headersSent) {\n this._engine.writeHead(this._reqId, this.statusCode, this._headersFlat());\n this.headersSent = true;\n }\n ok = this._engine.write(this._reqId, chunk) !== false;\n } catch {\n this._logger.error('Failed to write response chunk', 'ResponseError');\n return false;\n }\n\n if (typeof callback === 'function') callback();\n return ok;\n }\n\n end(data?: any, encoding?: any, callback?: any) {\n if (typeof encoding === 'function') {\n callback = encoding;\n encoding = undefined;\n }\n // Guard on _ended, not headersSent: in streaming mode (writeHead/write)\n // the head is already flushed and end() must still complete the body\n if (this._ended) {\n if (typeof callback === 'function') callback();\n return this;\n }\n\n try {\n if (!this.headersSent) {\n // Terminal single-shot: status + headers + body in one native call\n this._engine.respond(\n this._reqId,\n this.statusCode,\n this._headersFlat(),\n data !== undefined && data !== null ? data : null\n );\n this.headersSent = true;\n } else {\n this._engine.end(this._reqId, data !== undefined && data !== null ? data : undefined);\n }\n this._emitDone();\n if (typeof callback === 'function') callback();\n } catch (err) {\n this._failSafe('Failed to end response', err);\n if (typeof callback === 'function') callback();\n }\n\n return this;\n }\n\n redirect(url: string, code?: number) {\n if (this.headersSent || this._ended) return;\n\n const redirectCode = code || 302;\n this.statusCode = redirectCode;\n this.setHeader('location', url.replace(/[\\r\\n]/g, ''));\n\n try {\n this._engine.respond(this._reqId, redirectCode, this._headersFlat(), null);\n this.headersSent = true;\n this._emitDone();\n } catch (err) {\n this._failSafe('Failed to send redirect', err);\n }\n }\n\n // Standardized response helpers\n 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 this.json(response);\n }\n\n 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 this.json(response);\n }\n\n // Common HTTP error helpers (automatically set status code)\n unauthorized(message: string = 'Authentication required') {\n this.statusCode = 401;\n this.json({\n success: false,\n error: 'Unauthorized',\n code: 'UNAUTHORIZED',\n message,\n });\n }\n\n forbidden(message: string = 'Insufficient permissions') {\n this.statusCode = 403;\n this.json({\n success: false,\n error: 'Forbidden',\n code: 'FORBIDDEN',\n message,\n });\n }\n\n notFound(resource: string = 'Resource') {\n this.statusCode = 404;\n this.json({\n success: false,\n error: 'Not Found',\n code: 'NOT_FOUND',\n message: `${resource} not found`,\n });\n }\n\n badRequest(message: string = 'Invalid request') {\n this.statusCode = 400;\n this.json({\n success: false,\n error: 'Bad Request',\n code: 'BAD_REQUEST',\n message,\n });\n }\n\n conflict(message: string) {\n this.statusCode = 409;\n this.json({\n success: false,\n error: 'Conflict',\n code: 'CONFLICT',\n message,\n });\n }\n\n internalError(message: string = 'Internal server error') {\n this.statusCode = 500;\n this.json({\n success: false,\n error: 'Internal Server Error',\n code: 'INTERNAL_ERROR',\n message,\n });\n }\n\n validationError(errors: Array<{ field: string; message: string; code?: string }>) {\n this.statusCode = 422;\n this.json({\n success: false,\n error: 'Validation Failed',\n code: 'VALIDATION_ERROR',\n errors,\n });\n }\n\n rateLimited(retryAfter?: number) {\n this.statusCode = 429;\n if (retryAfter) {\n this.setHeader('Retry-After', retryAfter.toString());\n }\n this.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 created<T = any>(data: T, location?: string) {\n this.statusCode = 201;\n if (location) {\n this.setHeader('Location', location);\n }\n this.json({\n success: true,\n data,\n });\n }\n\n noContent() {\n this.statusCode = 204;\n this.end();\n }\n\n paginated<T = any>(data: T[], pagination: { page: number; limit: number; total: number }) {\n const totalPages = Math.ceil(pagination.total / pagination.limit);\n this.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(name: string, value: string, options?: any) {\n // Percent-encode the value (matches the Node path and Express): an\n // unencoded value containing ';' or ',' would inject cookie attributes, and\n // control chars would make the native header validator silently drop the\n // whole Set-Cookie header.\n const parts = [name, '=', encodeURIComponent(value)];\n\n if (options) {\n // maxAge: 0 is meaningful (immediate expiry - clearCookie relies on it)\n if (options.maxAge !== undefined && options.maxAge !== null) {\n parts.push('; Max-Age=', String(options.maxAge));\n }\n if (options.expires) {\n const expires =\n options.expires instanceof Date ? options.expires.toUTCString() : String(options.expires);\n parts.push('; Expires=', expires);\n }\n if (options.domain) {\n parts.push('; Domain=', options.domain);\n }\n if (options.secure) {\n parts.push('; Secure');\n }\n if (options.httpOnly) {\n parts.push('; HttpOnly');\n }\n if (options.sameSite) {\n parts.push('; SameSite=', options.sameSite);\n }\n }\n // Path defaults to '/' (Express behavior): without it the browser scopes\n // the cookie to the current URL's directory, so a clearCookie() from\n // /auth/logout would miss a cookie originally set at Path=/.\n parts.push('; Path=', options?.path ?? '/');\n\n const cookie = parts.join('');\n const lowerKey = 'set-cookie';\n const existing = this.responseHeaders[lowerKey];\n if (existing) {\n if (Array.isArray(existing)) {\n existing.push(cookie);\n } else {\n this.responseHeaders[lowerKey] = [existing as string, cookie];\n }\n } else {\n this.responseHeaders[lowerKey] = cookie;\n }\n\n return this;\n }\n\n clearCookie(name: string, options: any = {}) {\n const clearOptions: any = { expires: new Date(0), maxAge: 0 };\n if (options.path !== undefined) clearOptions.path = options.path;\n if (options.domain !== undefined) clearOptions.domain = options.domain;\n if (options.httpOnly !== undefined) clearOptions.httpOnly = options.httpOnly;\n if (options.secure !== undefined) clearOptions.secure = options.secure;\n if (options.sameSite !== undefined) clearOptions.sameSite = options.sameSite;\n return this.cookie(name, '', clearOptions);\n }\n\n // ==== File responses ====\n\n // Small files go out in one respond(); larger files stream with\n // backpressure ('drain' via the engine's onWritable)\n async sendFile(filePath: string): Promise<void> {\n if (this.headersSent || this._ended) return;\n\n let streamRef: any = null; // read stream, so the catch can tear it down\n try {\n const fs = await import('fs');\n const path = await import('path');\n const stats = await fs.promises.stat(filePath);\n\n const contentType = addCharsetIfNeeded(mimeTypeFor(path.extname(filePath)));\n if (!('content-type' in this.responseHeaders)) {\n this.setHeader('Content-Type', contentType);\n }\n this.setHeader('X-Content-Type-Options', 'nosniff');\n this.setHeader('Last-Modified', stats.mtime.toUTCString());\n this.setHeader('Cache-Control', 'public, max-age=31536000');\n\n if (stats.size <= SENDFILE_BUFFER_LIMIT) {\n const data = await fs.promises.readFile(filePath);\n this.end(data);\n return;\n }\n\n // Explicit length so the engine skips chunked encoding for the stream.\n // (If the file shrinks mid-stream, the engine detects the short write at\n // end() and forces Connection: close - the client sees truncation, never\n // the next response's bytes as this body.)\n this.setHeader('Content-Length', String(stats.size));\n await new Promise<void>((resolve, reject) => {\n const stream = fs.createReadStream(filePath);\n streamRef = stream;\n let pendingResume: (() => void) | null = null;\n // ONE close listener for the stream's whole lifetime (not one per\n // backpressure pause), and it SETTLES the promise: a client abort\n // while the stream is paused must not leave `await sendFile()`\n // hanging forever.\n const onClose = () => {\n if (pendingResume) this.removeListener('drain', pendingResume);\n stream.destroy();\n resolve();\n };\n this.once('close', onClose);\n const cleanup = () => {\n this.removeListener('close', onClose);\n if (pendingResume) this.removeListener('drain', pendingResume);\n };\n stream.on('data', chunk => {\n if (this._ended) {\n cleanup();\n stream.destroy();\n resolve();\n return;\n }\n if (!this.write(chunk)) {\n stream.pause();\n pendingResume = () => {\n pendingResume = null;\n stream.resume();\n };\n this.once('drain', pendingResume);\n }\n });\n stream.on('end', () => {\n cleanup();\n this.end();\n resolve();\n });\n stream.on('error', (err: Error) => {\n cleanup();\n reject(err);\n });\n });\n } catch {\n // The head may already be on the wire (streaming branch). Terminate the\n // response so the client isn't left waiting on the declared\n // Content-Length, and tear down the read stream; only 404 if nothing was\n // sent yet.\n if (streamRef) streamRef.destroy();\n if (this.headersSent && !this._ended) {\n this.end();\n } else if (!this.headersSent && !this._ended) {\n this.status(404).json({ success: false, error: 'File not found' });\n }\n }\n }\n\n attachment(filename?: string) {\n if (this.headersSent) return this;\n if (filename) {\n const safeName = filename.replace(/[\\r\\n\"]/g, '');\n this.setHeader('Content-Disposition', `attachment; filename=\"${safeName}\"`);\n if (!this.getHeader('Content-Type')) {\n const dot = filename.lastIndexOf('.');\n if (dot !== -1) {\n this.setHeader('Content-Type', mimeTypeFor(filename.substring(dot)));\n }\n }\n } else {\n this.setHeader('Content-Disposition', 'attachment');\n }\n return this;\n }\n\n async download(filePath: string, filename?: string): Promise<void> {\n this.attachment(filename || filePath.split('/').pop());\n return this.sendFile(filePath);\n }\n\n format(handlers: Record<string, () => any | Promise<any>>): void {\n const types = Object.keys(handlers).filter(k => k !== 'default');\n const matched = this._moroReq ? this._moroReq.accepts(types) : false;\n const chosen = matched ? handlers[matched as string] : handlers.default;\n if (!chosen) {\n this.statusCode = 406;\n this.setHeader('Content-Type', 'text/plain; charset=utf-8');\n this.end('Not Acceptable');\n return;\n }\n this.vary('Accept');\n if (matched && typeof matched === 'string') {\n this.type(matched);\n }\n chosen();\n }\n\n // ==== Express-compatible response helpers (parity with the uWS adapter) ====\n\n set(field: string | Record<string, any>, value?: any) {\n if (this.headersSent) return this;\n if (typeof field === 'string') {\n if (value !== undefined) this.setHeader(field, value);\n } else {\n for (const key in field) {\n this.setHeader(key, field[key]);\n }\n }\n return this;\n }\n\n get(field: string) {\n return this.getHeader(field);\n }\n\n hasHeader(name: string): boolean {\n return this.getHeader(name) !== undefined;\n }\n\n setBulkHeaders(headers: Record<string, string | number>) {\n if (this.headersSent) return this;\n for (const key in headers) {\n this.setHeader(key, String(headers[key]));\n }\n return this;\n }\n\n appendHeader(name: string, value: string | string[]) {\n if (this.headersSent) return this;\n const lower = name.toLowerCase();\n const existing = this.responseHeaders[lower];\n if (existing) {\n const values = Array.isArray(existing) ? existing : [existing as string];\n const incoming = Array.isArray(value) ? value : [value];\n this.responseHeaders[lower] = values.concat(incoming);\n } else {\n this.responseHeaders[lower] = value;\n }\n return this;\n }\n\n append(field: string, value: string | string[]) {\n return this.appendHeader(field, value);\n }\n\n type(contentType: string) {\n if (this.headersSent) return this;\n let ct = contentType;\n if (ct.indexOf('/') === -1) {\n const shorthands: Record<string, string> = {\n json: 'application/json; charset=utf-8',\n html: 'text/html; charset=utf-8',\n text: 'text/plain; charset=utf-8',\n txt: 'text/plain; charset=utf-8',\n xml: 'application/xml',\n js: 'application/javascript',\n css: 'text/css; charset=utf-8',\n form: 'application/x-www-form-urlencoded',\n };\n ct = shorthands[ct.toLowerCase()] || `application/${ct}`;\n }\n this.setHeader('Content-Type', ct);\n return this;\n }\n\n sendStatus(code: number) {\n if (this.headersSent) return;\n this.statusCode = code;\n // Reason phrase when the code is known, otherwise the code itself\n // (Node behavior) - never a fabricated \"OK\" for a non-2xx status.\n const statusString = STATUS_STRINGS.get(code);\n const body = statusString ? statusString.slice(String(code).length + 1) : String(code);\n this.setHeader('Content-Type', 'text/plain; charset=utf-8');\n this.end(body);\n }\n\n location(url: string) {\n if (this.headersSent) return this;\n this.setHeader('Location', url.replace(/[\\r\\n]/g, ''));\n return this;\n }\n\n vary(field: string | string[]) {\n if (this.headersSent) return this;\n const existing = this.responseHeaders['vary'];\n const existingList = existing\n ? String(existing)\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n : [];\n const incoming = Array.isArray(field) ? field : [field];\n for (const f of incoming) {\n if (!existingList.some(e => e.toLowerCase() === f.toLowerCase())) {\n existingList.push(f);\n }\n }\n this.responseHeaders['vary'] = existingList.join(', ');\n return this;\n }\n\n links(links: Record<string, string>) {\n if (this.headersSent) return this;\n const parts: string[] = [];\n for (const rel in links) {\n parts.push(`<${links[rel]}>; rel=\"${rel}\"`);\n }\n if (parts.length > 0) {\n const existing = this.responseHeaders['link'];\n this.responseHeaders['link'] = existing\n ? `${existing}, ${parts.join(', ')}`\n : parts.join(', ');\n }\n return this;\n }\n\n canSetHeaders(): boolean {\n return !this.headersSent;\n }\n\n getResponseState() {\n return {\n headersSent: this.headersSent,\n statusCode: this.statusCode,\n headers: this.responseHeaders,\n finished: this._ended,\n writable: !this._ended,\n };\n }\n}\n\n/**\n * Moro Engine HTTP Server Adapter\n * Bridges @morojs/engine with Moro's HTTP abstractions. Duck-typed to the\n * same surface framework.ts/moro.ts use on UWebSocketsHttpServer.\n */\nexport class MoroEngineServer {\n /** @internal read by EngineRequest/EngineResponse for lazy fetchers */\n _engine: any;\n /** @internal read by EngineRequest#protocol/socket.encrypted - true when the\n * engine is terminating TLS for this server (engine >= 1.2.0 + ssl passed) */\n isSsl = false;\n\n private serverId: number;\n private globalMiddleware: Middleware[] = [];\n private logger = createFrameworkLogger('EngineHttpServer');\n private hookManager: any;\n private requestCounter = 0;\n private requestTrackingEnabled = true; // Generate request IDs (read lazily by EngineRequest)\n private isListening = false;\n private port?: number;\n private host?: string;\n // In-flight responses by reqId so onAborted/onWritable reach the wrappers;\n // entries are dropped on terminal writes (_complete) and aborts\n private inflight = new Map<number, EngineResponse>();\n // Small stable handle exposed via getServer()/getApp() (observability only)\n private handle: any;\n // Set by the engine WebSocket adapter when WS support is enabled; when\n // present, upgrade requests are routed to the engine's native WS path.\n // onOpen receives the handshake request's remote address and headers -\n // captured before the upgrade invalidates the reqId - so IP-based WS\n // rate limiting and header/token connection auth see real values.\n private _wsBridge?: {\n onOpen(\n wsId: number,\n path: string,\n info?: { ip: string; headers: Record<string, string>; query?: string }\n ): void;\n onMessage(wsId: number, data: any, isBinary: boolean): void;\n onClose(wsId: number, code: number): void;\n };\n // Handshake info for the upgrade currently in flight: set just before\n // upgradeToWebSocket() (which fires onWsOpen synchronously), consumed there.\n private _pendingWsInfo?:\n { ip: string; headers: Record<string, string>; query: string } | undefined;\n\n // Body size limits (bytes) - configured from server.bodySizeLimit/maxUploadSize\n private maxBodySize: number = 10 * 1024 * 1024;\n private maxUploadSize: number = 100 * 1024 * 1024;\n private reusePort = false;\n private _capabilities?: EngineCapabilities;\n private _limits?: HttpRuntimeLimits;\n private _ssl?: Record<string, any>;\n private _http2Settings?: Http2ServerOptions;\n private multipartLimits?: MultipartLimits;\n /** @internal read by EngineResponse for buffered-response compression */\n _compression: CompressionSettings = {\n enabled: false,\n threshold: 1024,\n level: 6,\n encodings: ['br', 'gzip', 'deflate'],\n };\n // Set by close(); listen() then registers a fresh native server, because the\n // old serverId's uv handles are torn down and must never be reused.\n private closed = false;\n\n // Direct router dispatch (set from Moro.listen via setRouterHandler)\n private routerHandler?: (req: HttpRequest, res: HttpResponse) => boolean | Promise<boolean>;\n\n // Global error handler (Moro.setErrorHandler) - shapes errors thrown from\n // global middleware, hooks and body parsing (parity with MoroHttpServer)\n private errorHandler?: (err: any, req: HttpRequest, res: HttpResponse) => any | Promise<any>;\n\n // Direct route table (parity with MoroHttpServer): routes registered via\n // get/post/... - the framework's registerDirectRoutes() calls these. They\n // live here, independent of the UnifiedRouter singleton, so app.post()-style\n // routes keep working even if the unified router is reset (as the test\n // harness does between cases). Checked before the unified router in dispatch.\n private directRoutes: Array<{\n method: string;\n pattern: RegExp;\n paramNames: string[];\n handlers: Array<Middleware | HttpHandler>;\n }> = [];\n\n constructor(\n options: {\n /** Normalized SSL config projected for the engine (both shapes). */\n ssl?: Record<string, any> | null;\n /** Engine feature flags (from loadNativeEngine) - gates the ssl/http2/\n * limit options so we never pass a key an older engine won't parse. */\n capabilities?: EngineCapabilities;\n /** Flattened runtime limits (bytes/ms) from the framework. */\n limits?: HttpRuntimeLimits;\n /** HTTP/2 settings when serving ALPN h2 natively (engine caps.http2). */\n http2Settings?: Http2ServerOptions;\n maxBodySize?: number;\n maxUploadSize?: number;\n /** Preloaded native engine module (from loadNativeEngine) - avoids a\n * second resolution and keeps load failures at the framework's\n * synchronous preflight instead of surfacing at listen() */\n engineModule?: any;\n /** Bind with SO_REUSEPORT so cluster workers can share the port\n * (POSIX only; the framework gates Windows clustering to Node) */\n reusePort?: boolean;\n } = {}\n ) {\n if (options.maxBodySize) this.maxBodySize = options.maxBodySize;\n if (options.maxUploadSize) this.maxUploadSize = options.maxUploadSize;\n this.reusePort = options.reusePort === true;\n if (options.capabilities) this._capabilities = options.capabilities;\n if (options.limits) this._limits = options.limits;\n if (options.ssl) this._ssl = options.ssl;\n if (options.http2Settings) this._http2Settings = options.http2Settings;\n if (options.limits?.multipart) this.multipartLimits = options.limits.multipart;\n\n // The framework preloads the engine synchronously (loadNativeEngine) and\n // injects it; loading here directly covers standalone construction.\n const engineModule = options.engineModule ?? loadNativeEngine()?.module;\n if (!engineModule) {\n throw new Error(\n 'No native HTTP engine available: ' +\n (getNativeEngineLoadErrors().join('; ') || 'not installed')\n );\n }\n const surface = engineModule.default || engineModule;\n if (typeof surface.serve !== 'function' || typeof surface.respond !== 'function') {\n throw new Error(\n 'Engine module does not provide the @morojs/engine API (serve/respond) - ' +\n 'use UWebSocketsHttpServer for uWS-style modules'\n );\n }\n this._engine = surface;\n\n // TLS: pass it through when the engine supports it; otherwise keep the\n // (now capability-gated) warning so a proxy/node fallback is clear.\n if (this._ssl && this._capabilities?.tls) {\n this.isSsl = true; // req.secure/protocol now report https\n } else if (this._ssl && !this._capabilities?.tls) {\n this.logger.warn(\n 'This @morojs/engine build does not terminate TLS - terminate at a ' +\n \"proxy, upgrade the engine, or set engine: 'node' for in-process HTTPS\",\n 'Init'\n );\n }\n\n // Register callbacks now - the engine opens sockets only at listen().\n this.serverId = this.registerWithEngine();\n\n // Framework observability handle exposed via getServer()/getApp(). It\n // mimics enough of a net.Server that code reaching for the raw server\n // (e.g. `app.core.httpServer.getServer().close(cb)`) works on the engine\n // path too - address() is null until listening, and close(cb) forwards to\n // the adapter's shutdown so callers never hang waiting on a missing method.\n this.handle = Object.defineProperties(\n {\n engine: '@morojs/engine',\n address: () =>\n this.isListening\n ? { address: this.host || '0.0.0.0', family: 'IPv4', port: this.port || 0 }\n : null,\n close: (cb?: (err?: Error) => void) => {\n this.close(cb);\n return this.handle;\n },\n },\n {\n serverId: { get: () => this.serverId, enumerable: true },\n listening: { get: () => this.isListening, enumerable: true },\n }\n );\n\n this.logger.info('Moro engine HTTP server created', 'Init');\n }\n\n /** @internal terminal write/abort cleanup - drops the reqId mapping */\n _complete(reqId: number): void {\n this.inflight.delete(reqId);\n }\n\n // Register callbacks + limits with the native engine, returning the new\n // serverId. Called from the constructor and again by listen() after a\n // close() (the old native server is gone; a restart needs a fresh one).\n // The engine buffers bodies natively and 413s over its limit; it cannot\n // see content types, so it gets the larger upload limit and parseBody\n // enforces the tighter non-multipart limit (mirrors the other servers).\n //\n // Every option beyond maxBodySize/reusePort is gated on engine capabilities\n // so this never hands a key an older engine build cannot parse (an unknown\n // option would just be ignored, but gating keeps the intent explicit).\n private registerWithEngine(): number {\n const caps = this._capabilities;\n const limits = this._limits;\n const t = limits?.timeouts ?? {};\n const serveOptions: Record<string, any> = {\n maxBodySize: Math.max(this.maxBodySize, this.maxUploadSize),\n reusePort: this.reusePort,\n };\n // Timeouts + connection cap: understood since the engine's first release.\n if (t.idle !== undefined) serveOptions.idleTimeoutMs = t.idle;\n if (t.request !== undefined) serveOptions.requestTimeoutMs = t.request;\n if (limits?.maxConnections && limits.maxConnections > 0) {\n serveOptions.maxConnections = limits.maxConnections;\n }\n if (limits?.maxPendingBytes !== undefined) {\n serveOptions.maxPendingBytes = limits.maxPendingBytes;\n }\n // Full limit surface (engine >= 1.1.0).\n if (caps?.limits) {\n if (limits?.maxHeaderSize !== undefined) serveOptions.maxHeadSize = limits.maxHeaderSize;\n if (limits?.maxHeaders !== undefined) serveOptions.maxHeaders = limits.maxHeaders;\n if (limits?.wsMaxMessageSize !== undefined)\n serveOptions.wsMaxMessageSize = limits.wsMaxMessageSize;\n if (limits?.wsBackpressureLimit !== undefined)\n serveOptions.wsBackpressureLimit = limits.wsBackpressureLimit;\n if (limits?.writeHighWaterMark !== undefined)\n serveOptions.writeHighWaterMark = limits.writeHighWaterMark;\n if (limits?.backlog !== undefined) serveOptions.backlog = limits.backlog;\n }\n // TLS: gated on the engine's own capability flag (caps.tls), not a version\n // number, so a mismatched engine build is never handed an ssl option it\n // can't parse.\n if (caps?.tls && this._ssl) {\n serveOptions.ssl = this._ssl;\n }\n // HTTP/2: likewise gated on caps.http2.\n if (caps?.http2 && this._http2Settings) {\n serveOptions.http2 = {\n ...(this._http2Settings.settings ?? {}),\n };\n }\n return this._engine.serve(\n {\n onRequest: (reqId: number, methodIdx: number, path: string) =>\n this.onRequest(reqId, methodIdx, path),\n onAborted: (reqId: number) => this.onAborted(reqId),\n onWritable: (reqId: number) => this.onWritable(reqId),\n onWsOpen: (wsId: number, path: string) =>\n this._wsBridge?.onOpen(wsId, path, this._pendingWsInfo),\n onWsMessage: (wsId: number, data: any, isBinary: boolean) =>\n this._wsBridge?.onMessage(wsId, data, isBinary),\n onWsClose: (wsId: number, code: number) => this._wsBridge?.onClose(wsId, code),\n },\n serveOptions\n );\n }\n\n // ---- WebSocket bridge (used by EngineWebSocketAdapter) ----\n\n /** Register the engine WebSocket bridge; upgrade requests then route natively. */\n enableWebSocket(bridge: {\n onOpen(wsId: number, path: string): void;\n onMessage(wsId: number, data: any, isBinary: boolean): void;\n onClose(wsId: number, code: number): void;\n }): void {\n this._wsBridge = bridge;\n }\n\n /** Send a frame on a WebSocket. Returns false on backpressure. */\n wsSend(wsId: number, data: string | ArrayBuffer | Buffer, isBinary: boolean): boolean {\n return this._engine.wsSend(wsId, data, isBinary) !== false;\n }\n\n /** Close a WebSocket (RFC 6455 close frame). */\n wsClose(wsId: number, code?: number, reason?: string): void {\n this._engine.wsClose(wsId, code, reason);\n }\n\n // Direct router dispatch - called after global middleware without the\n // per-middleware promise machinery (mirrors MoroHttpServer.setRouterHandler)\n setRouterHandler(fn: (req: HttpRequest, res: HttpResponse) => boolean | Promise<boolean>): void {\n this.routerHandler = fn;\n }\n\n // Register a global error handler (called from Moro.setErrorHandler)\n setErrorHandler(fn: (err: any, req: HttpRequest, res: HttpResponse) => any | Promise<any>): void {\n this.errorHandler = fn;\n }\n\n // Request/response decorations (app.decorateRequest/decorateReply). Applied\n // per request/response since EngineRequest/EngineResponse are shared classes\n // (decorating their prototype would leak across apps in one process). Empty\n // by default, so the common path pays only a `> 0` length check.\n private requestDecorationKeys: string[] = [];\n private requestDecorations: Record<string, any> = {};\n private responseDecorationKeys: string[] = [];\n private responseDecorations: Record<string, any> = {};\n\n setRequestDecorations(decorations: Record<string, any>): void {\n this.requestDecorations = decorations;\n this.requestDecorationKeys = Object.keys(decorations);\n }\n\n setResponseDecorations(decorations: Record<string, any>): void {\n this.responseDecorations = decorations;\n this.responseDecorationKeys = Object.keys(decorations);\n }\n\n // Direct route registration (mirrors MoroHttpServer). The framework's\n // registerDirectRoutes() invokes these as httpServer[method](path, handler).\n private addDirectRoute(\n method: string,\n path: string,\n handlers: Array<Middleware | HttpHandler>\n ): void {\n const compiled = PathMatcher.compile(path);\n const pattern =\n compiled.pattern || new RegExp(`^${(path.split('?')[0] ?? '').replace(/\\//g, '\\\\/')}$`);\n this.directRoutes.push({ method, pattern, paramNames: compiled.paramNames, handlers });\n }\n\n get(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('GET', path, handlers);\n }\n post(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('POST', path, handlers);\n }\n put(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('PUT', path, handlers);\n }\n delete(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('DELETE', path, handlers);\n }\n patch(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('PATCH', path, handlers);\n }\n options(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('OPTIONS', path, handlers);\n }\n head(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('HEAD', path, handlers);\n }\n\n // Match + run a direct route. Returns true if one handled the request.\n private async dispatchDirectRoute(\n httpReq: EngineRequest,\n httpRes: EngineResponse\n ): Promise<boolean> {\n if (this.directRoutes.length === 0) return false;\n const method = httpReq.method;\n const path = httpReq.path;\n for (const route of this.directRoutes) {\n if (route.method !== method) continue;\n const matches = path.match(route.pattern);\n if (!matches) continue;\n\n if (route.paramNames.length > 0) {\n const params: Record<string, string> = {};\n for (let i = 0; i < route.paramNames.length; i++) {\n const paramName = route.paramNames[i];\n if (paramName === undefined) continue;\n const raw = matches[i + 1];\n if (raw === undefined) {\n params[paramName] = '';\n } else {\n // Malformed escapes (e.g. /users/%zz) keep the raw text - a\n // URIError here would turn an odd URL into a 500\n try {\n params[paramName] = decodeURIComponent(raw);\n } catch {\n params[paramName] = raw;\n }\n }\n }\n httpReq.params = { ...httpReq.params, ...params };\n }\n\n // Run the handler chain: middleware-style (req,res,next) links run in\n // order; the final handler's return value (if any) is sent as JSON.\n for (let i = 0; i < route.handlers.length; i++) {\n if (httpRes.headersSent) break;\n const handler = route.handlers[i] as any;\n const isLast = i === route.handlers.length - 1;\n if (isLast) {\n const result = handler(httpReq as any, httpRes as any);\n const value = result && typeof result.then === 'function' ? await result : result;\n if (value !== undefined && !httpRes.headersSent) {\n (httpRes as any).json(value);\n }\n } else {\n await new Promise<void>((resolve, reject) => {\n let settled = false;\n const done = (err?: Error) => {\n if (settled) return;\n settled = true;\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n };\n try {\n const r = handler(httpReq as any, httpRes as any, done);\n if (r && typeof r.then === 'function') {\n r.then(() => done(), done);\n } else if (httpRes.headersSent) {\n // A middleware that ended the response without calling next()\n // would otherwise leave this await unresolved - unblock the chain.\n done();\n }\n } catch (e) {\n done(e as Error);\n }\n });\n }\n }\n return true;\n }\n return false;\n }\n\n // The engine has no native route table - every request already reaches the\n // unified router through a single onRequest callback with zero middleware\n // machinery, so there is no fast path to register. Accepted for interface\n // parity with the uWS adapter.\n setNativeRouteProvider(_provider: () => Array<any>, _onError?: (...args: any[]) => any): void {\n this.logger.debug(\n 'Native route provider noted (engine dispatch is already direct)',\n 'NativeRoutes'\n );\n }\n\n private onRequest(reqId: number, methodIdx: number, path: string): void {\n // WebSocket upgrade: when a WS bridge is registered and this is an upgrade\n // request, hand the connection to the engine's native WS path. The engine\n // sends the 101 handshake and drives onWsOpen/Message/Close.\n if (this._wsBridge) {\n const upgrade = this._engine.getHeader(reqId, 'upgrade');\n if (upgrade && upgrade.toLowerCase() === 'websocket') {\n // Snapshot handshake data now - the upgrade invalidates the reqId,\n // after which these fetchers return empty values.\n const ip: string = this._engine.getRemoteAddress(reqId) || '';\n const headers: Record<string, string> = {};\n const flat: string[] | undefined = this._engine.getHeaders(reqId);\n if (flat) {\n // Join duplicates exactly like the EngineRequest.headers getter -\n // last-wins would let a client send two X-Forwarded-For lines and\n // hide the earlier one from IP-based WS auth / rate-limiting.\n for (let i = 0; i + 1 < flat.length; i += 2) {\n const key = flat[i];\n const val = flat[i + 1];\n if (key === undefined || val === undefined) continue;\n const existing = headers[key];\n headers[key] =\n existing === undefined ? val : existing + (key === 'cookie' ? '; ' : ', ') + val;\n }\n }\n // Capture the query string too (invalidated by the upgrade like the\n // rest), so handlers can read handshake query params (e.g. orgId).\n const query: string = this._engine.getQuery(reqId) || '';\n this._pendingWsInfo = { ip, headers, query };\n const wsId = this._engine.upgradeToWebSocket(reqId);\n this._pendingWsInfo = undefined;\n if (wsId !== -1) return; // WS took over this connection\n // else: not a valid upgrade - fall through to normal HTTP handling\n }\n }\n\n // methodIdx 7 (OTHER) needs the extra crossing; the seven common methods\n // resolve from the static table\n const method = methodIdx === 7 ? this._engine.getMethod(reqId) || 'OTHER' : METHODS[methodIdx];\n\n const httpReq = new EngineRequest(this, reqId, method, path);\n const httpRes = new EngineResponse(this, reqId, this.logger);\n httpRes._moroReq = httpReq;\n\n // Apply app.decorateRequest/decorateReply values (rare; opt-in)\n if (this.requestDecorationKeys.length > 0) {\n for (const key of this.requestDecorationKeys) {\n (httpReq as any)[key] = this.requestDecorations[key];\n }\n }\n if (this.responseDecorationKeys.length > 0) {\n for (const key of this.responseDecorationKeys) {\n (httpRes as any)[key] = this.responseDecorations[key];\n }\n }\n\n void this.handleRequest(httpReq, httpRes);\n\n // Register for onAborted/onWritable routing only when the response is\n // still in flight after the synchronous dispatch window. Sync handlers\n // have already ended by here, and the engine never fires those callbacks\n // for a completed reqId - registering every request just churns this\n // long-lived Map's old-space backing store, and entries alive at a\n // scavenge promote the whole request/response graph (at ~570k pipelined\n // req/s that meant full GCs every ~400ms and a ~150 MB heap vs ~30 MB).\n if (!httpRes.writableEnded) this.inflight.set(reqId, httpRes);\n }\n\n private onAborted(reqId: number): void {\n const httpRes = this.inflight.get(reqId);\n if (httpRes) {\n this.inflight.delete(reqId);\n httpRes._handleAbort();\n }\n }\n\n private onWritable(reqId: number): void {\n const httpRes = this.inflight.get(reqId);\n if (httpRes) httpRes._handleWritable();\n }\n\n private async handleRequest(httpReq: EngineRequest, httpRes: EngineResponse): Promise<void> {\n this.requestCounter++;\n\n try {\n const method = httpReq.method;\n\n // Parse body only for body methods (all start with 'P'). The engine\n // buffered the body before onRequest fired, so this is synchronous.\n if (\n method.charCodeAt(0) === 80 && // 'P' char code\n (method === 'POST' || method === 'PUT' || method === 'PATCH')\n ) {\n this.parseBody(httpReq);\n }\n\n // Execute hooks before request processing - skipped entirely when none registered\n const hookManager = this.hookManager;\n if (hookManager && (hookManager.hasHooks === undefined || hookManager.hasHooks('request'))) {\n await hookManager.execute('request', {\n request: httpReq,\n response: httpRes,\n });\n }\n\n // Post-response hooks (session persistence, auth session refresh, CDN\n // invalidation) run after the response is flushed, off the critical path.\n if (hookManager && (hookManager.hasHooks === undefined || hookManager.hasHooks('response'))) {\n httpRes.once('finish', () => {\n void Promise.resolve(\n 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 // Execute global middleware chain\n if (this.globalMiddleware.length > 0) {\n await this.executeMiddleware(\n this.globalMiddleware,\n httpReq as any as HttpRequest,\n httpRes as any as HttpResponse\n );\n if (httpRes.headersSent) return;\n }\n\n // Unified router first - it carries the full route feature set\n // (per-route middleware, validation, auth, ...). The direct route table\n // below is only a fallback for when the unified router singleton was\n // reset out from under a listening app (as the test harness does), so it\n // must never shadow the richer unified-router path.\n const routerHandler = this.routerHandler;\n if (routerHandler) {\n const handled = routerHandler(\n httpReq as any as HttpRequest,\n httpRes as any as HttpResponse\n );\n if (handled) {\n if (typeof (handled as any).then === 'function') {\n if (await handled) return;\n } else {\n return;\n }\n }\n }\n\n // Direct route table fallback (parity with node's dual registration -\n // survives a UnifiedRouter reset)\n if (await this.dispatchDirectRoute(httpReq, httpRes)) return;\n\n // No route matched\n if (!httpRes.headersSent && !httpRes.writableEnded) {\n httpRes.statusCode = 404;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Not found\"}');\n }\n } catch (error) {\n // Payload-too-large: respond 413 rather than a generic 500\n if ((error as any)?.statusCode === 413 && !httpRes.writableEnded && !httpRes.headersSent) {\n httpRes.statusCode = 413;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Request entity too large\"}');\n return;\n }\n\n // Malformed body (parseBody): a client error, not a server error\n if ((error as any)?.statusCode === 400 && !httpRes.writableEnded && !httpRes.headersSent) {\n httpRes.statusCode = 400;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Invalid request body\"}');\n return;\n }\n\n this.logger.error(\n `Request handling error: ${error instanceof Error ? error.message : String(error)}`,\n 'RequestError'\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 const errorHooks = this.hookManager;\n if (errorHooks && (errorHooks.hasHooks === undefined || errorHooks.hasHooks('error'))) {\n void Promise.resolve(\n errorHooks.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 // The app's global error handler (Moro.setErrorHandler) gets first shot\n // at shaping the response - same contract as the Node server.\n if (this.errorHandler && !httpRes.writableEnded && !httpRes.headersSent) {\n try {\n await this.errorHandler(\n error,\n httpReq as any as HttpRequest,\n httpRes as any as HttpResponse\n );\n if (httpRes.headersSent || httpRes.writableEnded) return;\n } catch (handlerError) {\n this.logger.error(\n `Error handler threw: ${handlerError instanceof Error ? handlerError.message : String(handlerError)}`,\n 'ErrorHandler'\n );\n }\n }\n\n // Send error response if not already sent\n if (!httpRes.writableEnded && !httpRes.headersSent) {\n try {\n httpRes.statusCode = 500;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Internal server error\"}');\n } catch {\n this.logger.error('Failed to send error response', 'ResponseError');\n }\n }\n }\n }\n\n // Parse the engine-buffered body (JSON/urlencoded/multipart/text - identical\n // semantics to the Node and uWS servers' readBody). getBody returns a STABLE\n // ArrayBuffer copy, so Buffer.from() views it with no aliasing hazard.\n private parseBody(httpReq: EngineRequest): void {\n const raw: ArrayBuffer | null = this._engine.getBody(httpReq._reqId);\n if (!raw || raw.byteLength === 0) return;\n\n const contentType = httpReq.headers['content-type'] || '';\n const isMultipart = contentType.includes('multipart/form-data');\n const maxSize = isMultipart ? this.maxUploadSize : this.maxBodySize;\n\n // The engine natively enforces the larger of the two limits; the tighter\n // non-multipart limit is enforced here (responds 413 via handleRequest)\n if (raw.byteLength > maxSize) {\n const error: any = new Error(\n isMultipart ? 'File upload too large' : 'Request body too large'\n );\n error.statusCode = 413;\n throw error;\n }\n\n const buffer = Buffer.from(raw);\n\n try {\n if (contentType.includes('application/json')) {\n httpReq.body = JSON.parse(buffer.toString('utf-8'));\n } else if (contentType.includes('application/x-www-form-urlencoded')) {\n const params = new URLSearchParams(buffer.toString('utf-8'));\n const body: Record<string, any> = {};\n params.forEach((value, key) => {\n body[key] = value;\n });\n httpReq.body = body;\n } else if (isMultipart) {\n // Shared parser (same as the Node/uWS servers) - stringifying\n // multipart would corrupt binary uploads and lose fields/files\n httpReq.body = parseMultipartBuffer(buffer, contentType, this.multipartLimits);\n } else {\n httpReq.body = buffer.toString('utf-8');\n }\n } catch (parseError) {\n // A limit error (multipart maxParts/maxFiles/maxFileSize) carries its own\n // 413 - preserve it rather than masking it as a generic 400 malformed.\n if (parseError && typeof (parseError as any).statusCode === 'number') {\n throw parseError;\n }\n // A malformed body must fail the request (Node-path parity), not slip a\n // silent `body = null` past handlers that then treat it as \"no input\".\n const error: any = new Error(\n `Invalid request body: ${parseError instanceof Error ? parseError.message : String(parseError)}`\n );\n error.statusCode = 400;\n throw error;\n }\n }\n\n private async executeMiddleware(\n middleware: Middleware[],\n req: HttpRequest,\n res: HttpResponse\n ): Promise<void> {\n // Express error semantics: a middleware that calls next(err) (or throws)\n // routes to the NEXT 4-arg error handler (err, req, res, next), skipping\n // the normal 3-arg middleware in between; normal middleware is skipped\n // while an error is pending, and error handlers are skipped when there is\n // no error. An uncaught error propagates to handleRequest's 500 path.\n let error: any = null;\n for (const mw of middleware) {\n if (res.headersSent) break;\n const isErrorHandler = (mw as any).length >= 4;\n if (error && !isErrorHandler) continue;\n if (!error && isErrorHandler) continue;\n\n try {\n await new Promise<void>((resolve, reject) => {\n const next = (err?: any) => (err ? reject(err) : resolve());\n try {\n const result = error ? (mw as any)(error, req, res, next) : mw(req, res, next);\n if (result && typeof result.then === 'function') {\n result.then(() => resolve(), reject);\n }\n } catch (e) {\n reject(e);\n }\n });\n error = null; // handler (error or normal) completed cleanly\n } catch (e) {\n error = e; // route to the next error handler\n }\n }\n if (error) throw error;\n }\n\n // Public API - matches MoroHttpServer/UWebSocketsHttpServer interface\n\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 // Configure request tracking (ID generation)\n setRequestTracking(enabled: boolean): void {\n this.requestTrackingEnabled = enabled;\n }\n\n // Note: Route registration methods (get, post, etc.) are not used by the\n // engine adapter - all routing is handled by UnifiedRouter via setRouterHandler\n // (same as the uWS adapter)\n\n setHookManager(hookManager: any): void {\n this.hookManager = hookManager;\n }\n\n configurePerformance(config: any): void {\n // The engine's request hot path is batched natively; the one thing it\n // does NOT do itself is response compression, so wire that here (parity\n // with the Node path). Buffered responses only - streaming stays raw.\n this._compression = resolveCompressionSettings(config);\n this.logger.debug(\n `Performance configured (compression ${this._compression.enabled ? 'on' : 'off'})`,\n 'Config'\n );\n }\n\n listen(port: number, callback?: () => void): void;\n listen(port: number, host: string, callback?: () => void): void;\n listen(port: number, hostOrCallback?: string | (() => void), callback?: () => void): void {\n if (this.isListening) {\n this.logger.warn('Server is already listening', 'Listen');\n return;\n }\n\n const host = typeof hostOrCallback === 'string' ? hostOrCallback : '0.0.0.0';\n const cb = typeof hostOrCallback === 'function' ? hostOrCallback : callback;\n\n try {\n // listen() after close(): the old native server's handles are torn\n // down (its serverId is dead) - register a fresh one, like a Node\n // http.Server supports close() -> listen() cycles.\n if (this.closed) {\n this.serverId = this.registerWithEngine();\n this.closed = false;\n }\n // Synchronous bind; throws on bind errors, returns the actual port\n // (meaningful when port 0 asks for an ephemeral one)\n const actualPort = this._engine.listen(this.serverId, host, port);\n this.port = typeof actualPort === 'number' ? actualPort : port;\n this.host = host;\n this.isListening = true;\n this.logger.info(`Moro engine HTTP server listening on ${host}:${this.port}`, 'Listen');\n if (cb) cb();\n } catch (error) {\n this.logger.error(\n `Failed to listen on port ${port}: ${error instanceof Error ? error.message : String(error)}`,\n 'Listen'\n );\n throw error;\n }\n }\n\n /** Bounded drain window for in-flight responses during close() */\n private static readonly CLOSE_DRAIN_MS = 2000;\n\n close(callback?: (error?: Error) => void): void {\n if (!this.isListening) {\n if (callback) callback();\n return;\n }\n\n try {\n this.isListening = false;\n this.closed = true;\n\n // Graceful shutdown: stop accepting first, give in-flight responses a\n // bounded window to finish, then tear down. Requests still open at\n // teardown get onAborted -> 'close' events, so SSE intervals/monitors\n // registered on req.on('close') are released, not leaked.\n // Middleware is intentionally kept: close() -> listen() must serve with\n // the same cors/auth/compression stack (Node http.Server parity).\n if (typeof this._engine.stopListening === 'function') {\n this._engine.stopListening(this.serverId);\n }\n\n const finish = () => {\n try {\n this._engine.close(this.serverId);\n } catch (error) {\n this.logger.error('Error closing server', 'Close', {\n error: error instanceof Error ? error.message : String(error),\n });\n if (callback) callback(error instanceof Error ? error : new Error(String(error)));\n return;\n }\n this.inflight.clear();\n this.logger.info('Moro engine HTTP server closed', 'Close');\n if (callback) {\n // Give the event loop time to process the engine's socket teardown\n // before invoking the callback (matches the uWS adapter)\n setTimeout(() => {\n callback();\n }, 50);\n }\n };\n\n if (this.inflight.size === 0) {\n finish();\n return;\n }\n const deadline = Date.now() + MoroEngineServer.CLOSE_DRAIN_MS;\n const poll = setInterval(() => {\n if (this.inflight.size === 0 || Date.now() >= deadline) {\n clearInterval(poll);\n finish();\n }\n }, 25);\n // The drain poll must never keep the process alive by itself\n (poll as any).unref?.();\n } catch (error) {\n this.logger.error('Error closing server', 'Close', {\n error: error instanceof Error ? error.message : String(error),\n });\n if (callback) callback(error instanceof Error ? error : new Error(String(error)));\n }\n }\n\n getServer(): any {\n // Stable observability handle (listening/address) - there is no app object\n return this.handle;\n }\n\n getApp(): any {\n return this.handle;\n }\n\n forceCleanup(): void {\n // Cleanup method for compatibility\n this.logger.debug('Force cleanup called', 'Cleanup');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"moro-engine-server.js","sourceRoot":"","sources":["../../../src/core/http/moro-engine-server.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AACxE,6EAA6E;AAC7E,gFAAgF;AAChF,gFAAgF;AAChF,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,2EAA2E;AAC3E,2CAA2C;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,gBAAgB,EAChB,yBAAyB,GAE1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,cAAc,IAAI,oBAAoB,GAEvC,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL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MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,OAAO,EAAE;gBACjD,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;YACH,IAAI,QAAQ;gBAAE,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;IAED,SAAS;QACP,2EAA2E;QAC3E,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YAAY;QACV,mCAAmC;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC","sourcesContent":["// Moro Engine HTTP Server Implementation (@morojs/engine)\n//\n// One of the three HTTP backends, kept deliberately separate from the others:\n// - MoroHttpServer (http-server.ts) -> Node's http module\n// - UWebSocketsHttpServer (uws-http-server.ts) -> uWebSockets.js (opt-in)\n// - MoroEngineServer (this file) -> @morojs/engine, Moro's own\n// from-scratch native engine\n//\n// Bridges the Moro-shaped native engine API (one JS crossing per request in,\n// one out - see the engine repo's docs/API.md) with Moro's HTTP abstractions.\n// Unlike the uWS adapter there is no materialize() hazard: every per-request\n// fetcher (getHeaders/getQuery/getBody/...) returns a stable snapshot, and the\n// body is already complete when onRequest fires. Keep-alive, Content-Length,\n// Date, chunked encoding, HEAD body suppression and native 413/400 are all\n// engine concerns - this adapter never sees them. No dependency on the uWS\n// adapter: shared helpers live in ./utils.\n\nimport { randomUUID } from 'crypto';\nimport { createFrameworkLogger } from '../logger/index.js';\nimport { HttpRequest, HttpResponse, HttpHandler, Middleware } from '../../types/http.js';\nimport {\n loadNativeEngine,\n getNativeEngineLoadErrors,\n type EngineCapabilities,\n} from '../utilities/package-utils.js';\nimport {\n parseMultipart as parseMultipartBuffer,\n type MultipartLimits,\n} from './utils/multipart-parser.js';\nimport type { HttpRuntimeLimits } from './utils/size.js';\nimport type { Http2ServerOptions } from './http2-server.js';\nimport {\n resolveCompressionSettings,\n compressBuffer,\n isCompressible,\n negotiateEncoding,\n type CompressionSettings,\n} from './utils/compression.js';\nimport { LazyEventEmitter } from './utils/lazy-event-emitter.js';\nimport { parseRawQueryString as parseUwsQueryString } from './utils/query-parser.js';\nimport { PathMatcher } from '../routing/path-matcher.js';\n\n/** Engine method table - onRequest's methodIdx indexes into this */\nconst METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS', 'OTHER'] as const;\n\n// Pre-cached status strings for common codes (sendStatus bodies; the engine\n// derives the wire reason phrase from the numeric status itself)\nconst STATUS_STRINGS = new Map([\n [200, '200 OK'],\n [201, '201 Created'],\n [204, '204 No Content'],\n [301, '301 Moved Permanently'],\n [302, '302 Found'],\n [304, '304 Not Modified'],\n [400, '400 Bad Request'],\n [401, '401 Unauthorized'],\n [403, '403 Forbidden'],\n [404, '404 Not Found'],\n [500, '500 Internal Server Error'],\n [502, '502 Bad Gateway'],\n [503, '503 Service Unavailable'],\n]);\n\n// Same table as MoroHttpServer.getMimeType - kept sync here so attachment()\n// stays chainable without a fire-and-forget promise\nconst MIME_TYPES: Record<string, string> = {\n '.html': 'text/html',\n '.css': 'text/css',\n '.js': 'application/javascript',\n '.json': 'application/json',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n '.pdf': 'application/pdf',\n '.txt': 'text/plain',\n '.xml': 'application/xml',\n};\n\nfunction mimeTypeFor(ext: string): string {\n return MIME_TYPES[ext.toLowerCase()] || 'application/octet-stream';\n}\n\nfunction addCharsetIfNeeded(mimeType: string): string {\n if (\n mimeType.startsWith('text/') ||\n mimeType.startsWith('application/json') ||\n mimeType.startsWith('application/javascript') ||\n mimeType.startsWith('application/xml') ||\n mimeType.startsWith('image/svg+xml')\n ) {\n if (!mimeType.includes('charset')) {\n return `${mimeType}; charset=utf-8`;\n }\n }\n return mimeType;\n}\n\n// Files up to this size are sent with a single respond(); larger ones stream\n// through writeHead/write/end with backpressure respected via 'drain'\nconst SENDFILE_BUFFER_LIMIT = 1024 * 1024;\n\n// Shared flat header pair for the json() fast path - passed to respond() when\n// the response has no user-set headers, so no header object or flat array is\n// allocated. The engine only reads it; never mutate.\nconst JSON_HEADER_PAIR = ['content-type', 'application/json'];\n\n/**\n * Prototype-based request object for the engine adapter.\n *\n * Headers/query/cookies/ip/requestId are lazy: a synchronous handler that\n * never reads them pays nothing (no native crossing, no UUID). Every fetcher\n * returns a stable snapshot and reqIds are safe no-ops after the response\n * terminates, so - unlike the uWS adapter - there is no validity window.\n */\nexport class EngineRequest extends LazyEventEmitter {\n method: string;\n path: string;\n body: any = null;\n\n _server: MoroEngineServer;\n _reqId: number;\n _params: Record<string, string> | undefined = undefined;\n _url: string | undefined = undefined;\n _queryString: string | undefined = undefined;\n _query: Record<string, string> | undefined = undefined;\n _headers: Record<string, string> | undefined = undefined;\n _cookies: Record<string, string> | undefined = undefined;\n _context: Record<string, any> | undefined = undefined;\n _requestId: string | undefined = undefined;\n _ip: string | undefined = undefined;\n _socket: any = undefined;\n\n constructor(server: MoroEngineServer, reqId: number, method: string, path: string) {\n super();\n this._server = server;\n this._reqId = reqId;\n this.method = method;\n this.path = path;\n }\n\n /** Engine snapshots are stable - nothing to detach. No-op kept for\n * interface parity with UwsRequest so shared dispatch code can call it. */\n materialize(): void {}\n\n // Lazy like context: dispatch writes params through the setter only for\n // parametric routes, so a handler that never reads req.params on a static\n // route pays no allocation.\n get params(): Record<string, string> {\n let p = this._params;\n if (p === undefined) {\n p = {};\n this._params = p;\n }\n return p;\n }\n set params(value: Record<string, string>) {\n this._params = value;\n }\n\n private _rawQueryString(): string {\n let qs = this._queryString;\n if (qs === undefined) {\n // Safe no-op (undefined) after the response terminates - coerce to ''\n qs = this._server._getQuery(this._reqId) ?? '';\n this._queryString = qs as string;\n }\n return qs as string;\n }\n\n get url(): string {\n let u = this._url;\n if (u === undefined) {\n const qs = this._rawQueryString();\n u = qs ? `${this.path}?${qs}` : this.path;\n this._url = u;\n }\n return u;\n }\n set url(value: string) {\n this._url = value;\n }\n\n get query(): Record<string, string> {\n let q = this._query;\n if (q === undefined) {\n const qs = this._rawQueryString();\n q = qs ? parseUwsQueryString(qs) : {};\n this._query = q;\n }\n return q;\n }\n set query(value: Record<string, string>) {\n this._query = value;\n }\n\n get headers(): Record<string, string> {\n let h = this._headers;\n if (h === undefined) {\n h = {};\n // One crossing: flat [k1,v1,k2,v2,...] with keys already lowercased.\n // Duplicate header lines are joined like Node's IncomingMessage ('; '\n // for cookie, ', ' otherwise) - last-wins would let a client hide\n // earlier X-Forwarded-For entries from IP-based middleware.\n const flat: string[] | undefined = this._server._getHeaders(this._reqId);\n if (flat) {\n for (let i = 0; i + 1 < flat.length; i += 2) {\n const key = flat[i];\n const val = flat[i + 1];\n if (key === undefined || val === undefined) continue;\n const existing = h[key];\n if (existing === undefined) {\n h[key] = val;\n } else {\n h[key] = existing + (key === 'cookie' ? '; ' : ', ') + val;\n }\n }\n }\n this._headers = h;\n }\n return h;\n }\n set headers(value: Record<string, string>) {\n this._headers = value;\n }\n\n get cookies(): Record<string, string> {\n let c = this._cookies;\n if (c === undefined) {\n c = {};\n const header = this.headers.cookie;\n if (header) {\n const parts = header.split(';');\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if (part === undefined) continue;\n const eq = part.indexOf('=');\n if (eq > 0) {\n const name = part.substring(0, eq).trim();\n const value = part.substring(eq + 1);\n if (name && value) {\n try {\n c[name] = decodeURIComponent(value);\n } catch {\n c[name] = value;\n }\n }\n }\n }\n }\n this._cookies = c;\n }\n return c;\n }\n set cookies(value: Record<string, string>) {\n this._cookies = value;\n }\n\n get context(): Record<string, any> {\n let ctx = this._context;\n if (ctx === undefined) {\n ctx = {};\n this._context = ctx;\n }\n return ctx;\n }\n set context(value: Record<string, any>) {\n this._context = value;\n }\n\n get requestId(): string {\n let id = this._requestId;\n if (id === undefined) {\n const server = this._server;\n id = server && (server as any).requestTrackingEnabled ? randomUUID() : '';\n this._requestId = id;\n }\n return id;\n }\n set requestId(value: string) {\n this._requestId = value;\n }\n\n get ip(): string {\n let ip = this._ip;\n if (ip === undefined) {\n ip = this._server._getRemoteAddress(this._reqId) ?? '';\n this._ip = ip as string;\n }\n return ip as string;\n }\n set ip(value: string) {\n this._ip = value;\n }\n\n // Minimal net.Socket-shaped shim. `encrypted` reflects whether the engine\n // is terminating TLS for this server (engine >= 1.2.0); when it isn't and\n // TLS is proxy-terminated, middleware should read `x-forwarded-proto`. This\n // exists so code written against Node's IncomingMessage (req.socket.encrypted,\n // the CSRF middleware; req.connection.remoteAddress, rate-limiters) doesn't\n // throw on the engine transport. `connection` is the legacy alias for `socket`.\n get socket(): any {\n let s = this._socket;\n if (s === undefined) {\n const getIp = () => this.ip; // arrow captures this lexically (no this-alias)\n const encrypted = Boolean((this._server as any)?.isSsl);\n s = {\n get remoteAddress() {\n return getIp() || undefined;\n },\n remotePort: undefined,\n encrypted,\n destroyed: false,\n };\n this._socket = s;\n }\n return s;\n }\n set socket(value: any) {\n this._socket = value;\n }\n\n get connection(): any {\n return this.socket;\n }\n set connection(value: any) {\n this._socket = value;\n }\n\n // ==== Express-compatible request helpers (parity with the uWS adapter) ====\n\n get hostname(): string {\n const host = this.headers.host || '';\n return host ? (host.split(':')[0] ?? '') : '';\n }\n\n get protocol(): string {\n const forwardedProto = this.headers['x-forwarded-proto'];\n if (forwardedProto) return (forwardedProto.split(',')[0] ?? '').trim();\n return this._server && (this._server as any).isSsl ? 'https' : 'http';\n }\n\n get secure(): boolean {\n return this.protocol === 'https';\n }\n\n get xhr(): boolean {\n const xrw = this.headers['x-requested-with'];\n return !!xrw && xrw.toLowerCase() === 'xmlhttprequest';\n }\n\n get originalUrl(): string {\n return this.url;\n }\n\n get ips(): string[] {\n const forwardedFor = this.headers['x-forwarded-for'];\n return forwardedFor\n ? forwardedFor\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n : [];\n }\n\n get subdomains(): string[] {\n const hostnameParts = this.hostname.split('.');\n return hostnameParts.length > 2 ? hostnameParts.slice(0, -2).reverse() : [];\n }\n\n get(name: string): string | undefined {\n const lower = name.toLowerCase();\n if (lower === 'referer' || lower === 'referrer') {\n return this.headers.referer || (this.headers as any).referrer;\n }\n return this.headers[lower];\n }\n\n header(name: string): string | undefined {\n return this.get(name);\n }\n\n is(type: string): boolean {\n const ct = this.headers['content-type'] || '';\n if (!ct) return false;\n const mime = (ct.split(';')[0] ?? '').trim().toLowerCase();\n const t = type.toLowerCase();\n if (t.indexOf('/') === -1) {\n return mime.endsWith(`/${t}`) || mime.endsWith(`+${t}`);\n }\n if (t.endsWith('/*')) {\n return mime.startsWith(t.slice(0, -1));\n }\n return mime === t;\n }\n\n accepts(types?: string | string[]): string | false {\n const accept = this.headers.accept || '*/*';\n if (!types) return accept;\n const wanted = Array.isArray(types) ? types : [types];\n if (accept === '*/*' || accept === '') return wanted[0] || false;\n const acceptTypes = accept.split(',').map(s => (s.split(';')[0] ?? '').trim().toLowerCase());\n for (const w of wanted) {\n const wl = w.toLowerCase();\n const wMime = wl.indexOf('/') === -1 ? `application/${wl}` : wl;\n for (const at of acceptTypes) {\n if (at === '*/*') return w;\n if (at === wMime) return w;\n if (at.endsWith('/*') && wMime.startsWith(at.slice(0, -1))) return w;\n }\n }\n return false;\n }\n\n acceptsLanguages(langs?: string | string[]): string | false {\n const acceptLang = this.headers['accept-language'] || '';\n if (!langs) return acceptLang || false;\n const wanted = Array.isArray(langs) ? langs : [langs];\n if (!acceptLang) return wanted[0] || false;\n const accepted = acceptLang\n .split(',')\n .map(s => {\n const parts = s.trim().split(';');\n const tag = (parts[0] ?? '').toLowerCase();\n const qPart = parts.find(p => p.trim().startsWith('q='));\n const q = qPart ? parseFloat(qPart.trim().slice(2)) : 1;\n return { tag, q: isNaN(q) ? 0 : q };\n })\n .filter(a => a.q > 0)\n .sort((a, b) => b.q - a.q);\n for (const { tag } of accepted) {\n for (const w of wanted) {\n const wl = w.toLowerCase();\n if (tag === '*' || tag === wl || tag.split('-')[0] === wl.split('-')[0]) return w;\n }\n }\n return false;\n }\n}\n\n/**\n * Prototype-based response object for the engine adapter. Same\n * MoroResponseMethods surface as the uWS adapter's ResponsePrototype.\n *\n * Terminal writes (json/send/end/redirect) go out as ONE respond() call -\n * status + headers + body in a single native crossing. Streaming responses\n * (writeHead/write/end) map to the engine's streaming API; the engine's\n * onWritable backpressure signal surfaces as the 'drain' event.\n */\nexport class EngineResponse extends LazyEventEmitter {\n public headersSent = false;\n public statusCode = 200;\n // The EngineRequest wrapper, linked by the server so lifecycle events reach\n // req.on('close') listeners (SSE cleanup, monitors)\n public _moroReq: any = null;\n /** @internal true while this response is in the server's inflight map */\n _registered = false;\n\n private _server: MoroEngineServer;\n private _reqId: number;\n private _logger: any;\n // Lazy: json/send/end on a response with no user-set headers never\n // materialize a header object (see _headersFlat / the json fast path)\n private _responseHeaders: Record<string, string | string[]> | undefined = undefined;\n private _locals: Record<string, any> | undefined = undefined;\n // Terminal-write latch: headersSent means \"head flushed\" (true mid-stream\n // after writeHead/write), _ended means the body is complete\n private _ended = false;\n private _aborted = false;\n\n constructor(server: MoroEngineServer, reqId: number, logger: any) {\n super();\n this._server = server;\n this._reqId = reqId;\n this._logger = logger;\n }\n\n get responseHeaders(): Record<string, string | string[]> {\n let h = this._responseHeaders;\n if (h === undefined) {\n h = {};\n this._responseHeaders = h;\n }\n return h;\n }\n set responseHeaders(value: Record<string, string | string[]>) {\n this._responseHeaders = value;\n }\n\n get locals(): Record<string, any> {\n let l = this._locals;\n if (l === undefined) {\n l = {};\n this._locals = l;\n }\n return l;\n }\n set locals(value: Record<string, any>) {\n this._locals = value;\n }\n\n get writableEnded() {\n return this._ended;\n }\n\n get writableFinished() {\n return this._ended;\n }\n\n get finished() {\n return this._ended;\n }\n\n get aborted() {\n return this._aborted;\n }\n\n // Node ServerResponse lifecycle: 'finish' then 'close' after the terminal\n // write; the request wrapper's 'close' fires too (IncomingMessage parity).\n // Also releases the reqId from the server's in-flight map.\n private _emitDone() {\n this._ended = true;\n // Sync responses end before onRequest's registration window, so they were\n // never in the inflight map - skip the wasted delete on a missing key\n if (this._registered) {\n this._registered = false;\n this._server._complete(this._reqId);\n }\n if (this._events) {\n this.emit('finish');\n this.emit('close');\n }\n const req = this._moroReq;\n if (req && req._events) req.emit('close');\n }\n\n // Client aborted: 'close' without 'finish' (Node semantics), plus\n // 'aborted'/'close' on the request wrapper. All later engine calls with\n // this reqId are safe no-ops, but the guards below skip them anyway.\n _handleAbort() {\n if (this._ended) return;\n this._ended = true;\n this._aborted = true;\n this._registered = false; // onAborted already dropped the map entry\n if (this._events) this.emit('close');\n const req = this._moroReq;\n if (req && req._events) {\n req.emit('aborted');\n req.emit('close');\n }\n }\n\n // Backpressure: the engine's onWritable relayed as the 'drain' event that\n // pipe() and manual streaming loops wait on\n _handleWritable() {\n this.emit('drain');\n }\n\n // Build the engine's flat [k1,v1,k2,v2,...] header array from headers\n // actually set. Multi-value headers (set-cookie) become separate pairs so\n // each goes out as its own header line.\n private _headersFlat(): string[] | null {\n const headers = this._responseHeaders;\n if (headers === undefined) return null;\n let flat: string[] | null = null;\n // Performance: for...in is the fastest way to iterate response headers\n for (const key in headers) {\n const value = headers[key];\n if (flat === null) flat = [];\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) flat.push(key, String(value[i]));\n } else {\n flat.push(key, String(value));\n }\n }\n return flat;\n }\n\n status(code: number) {\n this.statusCode = code;\n return this;\n }\n\n setHeader(name: string, value: string | string[]) {\n // Cache toLowerCase result to avoid repeated calls\n const lowerName = name.toLowerCase();\n this.responseHeaders[lowerName] = value;\n return this;\n }\n\n getHeader(name: string) {\n const headers = this._responseHeaders;\n return headers === undefined ? undefined : headers[name.toLowerCase()];\n }\n\n removeHeader(name: string) {\n const headers = this._responseHeaders;\n if (headers !== undefined) {\n const lowerName = name.toLowerCase();\n if (lowerName in headers) delete headers[lowerName];\n }\n return this;\n }\n\n json(data: any) {\n if (this.headersSent || this._ended) return;\n\n // Fast-path JSON serialization for common API patterns\n let body: string;\n\n // The interpolated fast path is only valid when `success` is a real boolean\n // (a string/number would produce invalid JSON like {\"success\":yes,...});\n // otherwise fall through to JSON.stringify.\n if (data && typeof data === 'object' && typeof data.success === 'boolean') {\n let keyCount = 0;\n let hasData = false;\n let hasError = false;\n let hasTotal = false;\n\n for (const key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n keyCount++;\n if (key === 'data') hasData = true;\n else if (key === 'error') hasError = true;\n else if (key === 'total') hasTotal = true;\n }\n }\n\n // JSON.stringify(undefined) yields the literal token \"undefined\"; guard the\n // interpolated branches so an explicit `data: undefined` doesn't corrupt\n // the body (fall through to JSON.stringify, which omits the key instead).\n if (\n keyCount === 3 &&\n hasData &&\n hasError &&\n data.data !== undefined &&\n data.error !== undefined\n ) {\n body = `{\"success\":${data.success},\"data\":${JSON.stringify(data.data)},\"error\":${JSON.stringify(data.error)}}`;\n } else if (\n keyCount === 3 &&\n hasData &&\n hasTotal &&\n data.data !== undefined &&\n typeof data.total === 'number'\n ) {\n body = `{\"success\":${data.success},\"data\":${JSON.stringify(data.data)},\"total\":${data.total}}`;\n } else if (keyCount === 2 && hasData && data.data !== undefined) {\n body = `{\"success\":${data.success},\"data\":${JSON.stringify(data.data)}}`;\n } else if (keyCount === 2 && hasError && data.error !== undefined) {\n body = `{\"success\":${data.success},\"error\":${JSON.stringify(data.error)}}`;\n } else {\n body = JSON.stringify(data);\n }\n } else {\n body = JSON.stringify(data);\n }\n\n try {\n const rh = this._responseHeaders;\n if (rh === undefined && !this._server._compression.enabled) {\n // Hot path: no user-set headers, no compression - one native call\n // with the shared content-type pair; zero per-response header work\n this._server._respond(this._reqId, this.statusCode, JSON_HEADER_PAIR, body);\n this.headersSent = true;\n this._emitDone();\n return;\n }\n if (rh === undefined || !('content-type' in rh)) {\n this.responseHeaders['content-type'] = 'application/json';\n }\n this._respondMaybeCompressed(body, 'application/json');\n } catch (err) {\n this._failSafe('Failed to send JSON response', err);\n }\n }\n\n // Buffered-response compression parity with the Node path. Terminal helper:\n // respond() with `body`, compressing first when enabled + compressible +\n // over threshold + the client accepts an encoding. Keeps the synchronous\n // fast path (zero extra work) whenever compression can't apply, so the\n // default (compression off) pays nothing.\n private _respondMaybeCompressed(body: string | Buffer, contentType?: string): void {\n const s = this._server._compression;\n // HOT PATH: compression is off by default - bail before ANY per-response\n // work (byteLength scans the string; header reads allocate nothing but\n // still cost). The default config must pay zero for this feature.\n if (!s.enabled) {\n this._server._respond(this._reqId, this.statusCode, this._headersFlat(), body);\n this.headersSent = true;\n this._emitDone();\n return;\n }\n const bytes = typeof body === 'string' ? Buffer.byteLength(body) : body.length;\n const rh = this._responseHeaders;\n const alreadyEncoded = rh !== undefined && 'content-encoding' in rh;\n const ctHeader = rh?.['content-type'];\n const ct = contentType ?? (Array.isArray(ctHeader) ? ctHeader[0] : ctHeader);\n if (\n alreadyEncoded ||\n bytes < s.threshold ||\n !isCompressible(ct) ||\n this.statusCode === 204 ||\n this.statusCode === 304\n ) {\n this._server._respond(this._reqId, this.statusCode, this._headersFlat(), body);\n this.headersSent = true;\n this._emitDone();\n return;\n }\n\n const accept = this._server._getHeader(this._reqId, 'accept-encoding') as string | undefined;\n const encoding = negotiateEncoding(accept, s.encodings);\n if (!encoding) {\n this._server._respond(this._reqId, this.statusCode, this._headersFlat(), body);\n this.headersSent = true;\n this._emitDone();\n return;\n }\n\n // Async path: compress, then respond (guarding against an abort that\n // raced the await - the reqId would be invalid).\n void compressBuffer(body, encoding, s.level)\n .then(compressed => {\n if (this._ended || this._server._isAborted(this._reqId)) return;\n this.responseHeaders['content-encoding'] = encoding;\n const vary = this.responseHeaders['vary'];\n this.responseHeaders['vary'] = vary ? `${vary}, Accept-Encoding` : 'Accept-Encoding';\n this._server._respond(this._reqId, this.statusCode, this._headersFlat(), compressed);\n this.headersSent = true;\n this._emitDone();\n })\n .catch(err => this._failSafe('Failed to compress response', err));\n }\n\n // A response-send failure must never leave the request hanging open (the\n // sweep exempts active requests, so nothing else would ever close it):\n // attempt a plain 500, then release the wrapper either way.\n private _failSafe(context: string, err: unknown) {\n this._logger.error(\n `${context}: ${err instanceof Error ? err.message : String(err)}`,\n 'ResponseError'\n );\n if (!this._ended) {\n try {\n this._server._respond(\n this._reqId,\n 500,\n null,\n '{\"success\":false,\"error\":\"Internal server error\"}'\n );\n this.headersSent = true;\n } catch {\n // reqId already gone (aborted/finished) - nothing to send\n }\n this._emitDone();\n }\n }\n\n send(data: string | Buffer) {\n if (this.headersSent || this._ended) return;\n\n // Default a Content-Type to match the Node server (parity for the now-\n // default engine path): JSON for JSON-looking strings, octet-stream for\n // Buffers, text/plain otherwise.\n if (!('content-type' in this.responseHeaders)) {\n if (typeof data === 'string') {\n const t = data.trimStart();\n this.responseHeaders['content-type'] =\n t.startsWith('{') || t.startsWith('[')\n ? 'application/json; charset=utf-8'\n : 'text/plain; charset=utf-8';\n } else {\n this.responseHeaders['content-type'] = 'application/octet-stream';\n }\n }\n\n try {\n // Buffers pass through binary-safe (the engine accepts Uint8Array).\n // Compression applies only to compressible content types (isCompressible\n // excludes octet-stream), so binary sends stay on the sync fast path.\n this._respondMaybeCompressed(data);\n // headersSent/_emitDone handled inside the helper.\n } catch (err) {\n this._failSafe('Failed to send response', err);\n }\n }\n\n // Flush status + headers without ending the response (Node streaming\n // entry point - SSE and manual chunked responses start here). Supports\n // both (code, headers) and (code, statusMessage, headers) signatures;\n // the engine derives the reason phrase from the status code, so a custom\n // message cannot be sent on the wire and is ignored.\n writeHead(statusCode: number, reasonOrHeaders?: any, maybeHeaders?: any) {\n if (this.headersSent || this._ended) return this;\n\n this.statusCode = statusCode;\n const headers =\n reasonOrHeaders && typeof reasonOrHeaders === 'object' ? reasonOrHeaders : maybeHeaders;\n if (headers) {\n for (const key of Object.keys(headers)) {\n this.setHeader(key, headers[key]);\n }\n }\n\n try {\n this._server._writeHead(this._reqId, statusCode, this._headersFlat());\n this.headersSent = true;\n } catch {\n this._logger.error('Failed to write response head', 'ResponseError');\n }\n\n return this;\n }\n\n // Stream a body chunk, flushing the head first if needed. Returns the\n // engine's backpressure signal like Node's Writable.write; 'drain' fires\n // (via onWritable) when the socket can accept more.\n write(chunk: any, encoding?: any, callback?: any): boolean {\n if (typeof encoding === 'function') {\n callback = encoding;\n encoding = undefined;\n }\n if (this._ended) return false;\n\n let ok = true;\n try {\n if (!this.headersSent) {\n this._server._writeHead(this._reqId, this.statusCode, this._headersFlat());\n this.headersSent = true;\n }\n ok = this._server._write(this._reqId, chunk) !== false;\n } catch {\n this._logger.error('Failed to write response chunk', 'ResponseError');\n return false;\n }\n\n if (typeof callback === 'function') callback();\n return ok;\n }\n\n end(data?: any, encoding?: any, callback?: any) {\n if (typeof encoding === 'function') {\n callback = encoding;\n encoding = undefined;\n }\n // Guard on _ended, not headersSent: in streaming mode (writeHead/write)\n // the head is already flushed and end() must still complete the body\n if (this._ended) {\n if (typeof callback === 'function') callback();\n return this;\n }\n\n try {\n if (!this.headersSent) {\n // Terminal single-shot: status + headers + body in one native call\n this._server._respond(\n this._reqId,\n this.statusCode,\n this._headersFlat(),\n data !== undefined && data !== null ? data : null\n );\n this.headersSent = true;\n } else {\n this._server._end(this._reqId, data !== undefined && data !== null ? data : undefined);\n }\n this._emitDone();\n if (typeof callback === 'function') callback();\n } catch (err) {\n this._failSafe('Failed to end response', err);\n if (typeof callback === 'function') callback();\n }\n\n return this;\n }\n\n redirect(url: string, code?: number) {\n if (this.headersSent || this._ended) return;\n\n const redirectCode = code || 302;\n this.statusCode = redirectCode;\n this.setHeader('location', url.replace(/[\\r\\n]/g, ''));\n\n try {\n this._server._respond(this._reqId, redirectCode, this._headersFlat(), null);\n this.headersSent = true;\n this._emitDone();\n } catch (err) {\n this._failSafe('Failed to send redirect', err);\n }\n }\n\n // Standardized response helpers\n 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 this.json(response);\n }\n\n 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 this.json(response);\n }\n\n // Common HTTP error helpers (automatically set status code)\n unauthorized(message: string = 'Authentication required') {\n this.statusCode = 401;\n this.json({\n success: false,\n error: 'Unauthorized',\n code: 'UNAUTHORIZED',\n message,\n });\n }\n\n forbidden(message: string = 'Insufficient permissions') {\n this.statusCode = 403;\n this.json({\n success: false,\n error: 'Forbidden',\n code: 'FORBIDDEN',\n message,\n });\n }\n\n notFound(resource: string = 'Resource') {\n this.statusCode = 404;\n this.json({\n success: false,\n error: 'Not Found',\n code: 'NOT_FOUND',\n message: `${resource} not found`,\n });\n }\n\n badRequest(message: string = 'Invalid request') {\n this.statusCode = 400;\n this.json({\n success: false,\n error: 'Bad Request',\n code: 'BAD_REQUEST',\n message,\n });\n }\n\n conflict(message: string) {\n this.statusCode = 409;\n this.json({\n success: false,\n error: 'Conflict',\n code: 'CONFLICT',\n message,\n });\n }\n\n internalError(message: string = 'Internal server error') {\n this.statusCode = 500;\n this.json({\n success: false,\n error: 'Internal Server Error',\n code: 'INTERNAL_ERROR',\n message,\n });\n }\n\n validationError(errors: Array<{ field: string; message: string; code?: string }>) {\n this.statusCode = 422;\n this.json({\n success: false,\n error: 'Validation Failed',\n code: 'VALIDATION_ERROR',\n errors,\n });\n }\n\n rateLimited(retryAfter?: number) {\n this.statusCode = 429;\n if (retryAfter) {\n this.setHeader('Retry-After', retryAfter.toString());\n }\n this.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 created<T = any>(data: T, location?: string) {\n this.statusCode = 201;\n if (location) {\n this.setHeader('Location', location);\n }\n this.json({\n success: true,\n data,\n });\n }\n\n noContent() {\n this.statusCode = 204;\n this.end();\n }\n\n paginated<T = any>(data: T[], pagination: { page: number; limit: number; total: number }) {\n const totalPages = Math.ceil(pagination.total / pagination.limit);\n this.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(name: string, value: string, options?: any) {\n // Percent-encode the value (matches the Node path and Express): an\n // unencoded value containing ';' or ',' would inject cookie attributes, and\n // control chars would make the native header validator silently drop the\n // whole Set-Cookie header.\n const parts = [name, '=', encodeURIComponent(value)];\n\n if (options) {\n // maxAge: 0 is meaningful (immediate expiry - clearCookie relies on it)\n if (options.maxAge !== undefined && options.maxAge !== null) {\n parts.push('; Max-Age=', String(options.maxAge));\n }\n if (options.expires) {\n const expires =\n options.expires instanceof Date ? options.expires.toUTCString() : String(options.expires);\n parts.push('; Expires=', expires);\n }\n if (options.domain) {\n parts.push('; Domain=', options.domain);\n }\n if (options.secure) {\n parts.push('; Secure');\n }\n if (options.httpOnly) {\n parts.push('; HttpOnly');\n }\n if (options.sameSite) {\n parts.push('; SameSite=', options.sameSite);\n }\n }\n // Path defaults to '/' (Express behavior): without it the browser scopes\n // the cookie to the current URL's directory, so a clearCookie() from\n // /auth/logout would miss a cookie originally set at Path=/.\n parts.push('; Path=', options?.path ?? '/');\n\n const cookie = parts.join('');\n const lowerKey = 'set-cookie';\n const existing = this.responseHeaders[lowerKey];\n if (existing) {\n if (Array.isArray(existing)) {\n existing.push(cookie);\n } else {\n this.responseHeaders[lowerKey] = [existing as string, cookie];\n }\n } else {\n this.responseHeaders[lowerKey] = cookie;\n }\n\n return this;\n }\n\n clearCookie(name: string, options: any = {}) {\n const clearOptions: any = { expires: new Date(0), maxAge: 0 };\n if (options.path !== undefined) clearOptions.path = options.path;\n if (options.domain !== undefined) clearOptions.domain = options.domain;\n if (options.httpOnly !== undefined) clearOptions.httpOnly = options.httpOnly;\n if (options.secure !== undefined) clearOptions.secure = options.secure;\n if (options.sameSite !== undefined) clearOptions.sameSite = options.sameSite;\n return this.cookie(name, '', clearOptions);\n }\n\n // ==== File responses ====\n\n // Small files go out in one respond(); larger files stream with\n // backpressure ('drain' via the engine's onWritable)\n async sendFile(filePath: string): Promise<void> {\n if (this.headersSent || this._ended) return;\n\n let streamRef: any = null; // read stream, so the catch can tear it down\n try {\n const fs = await import('fs');\n const path = await import('path');\n const stats = await fs.promises.stat(filePath);\n\n const contentType = addCharsetIfNeeded(mimeTypeFor(path.extname(filePath)));\n if (!('content-type' in this.responseHeaders)) {\n this.setHeader('Content-Type', contentType);\n }\n this.setHeader('X-Content-Type-Options', 'nosniff');\n this.setHeader('Last-Modified', stats.mtime.toUTCString());\n this.setHeader('Cache-Control', 'public, max-age=31536000');\n\n if (stats.size <= SENDFILE_BUFFER_LIMIT) {\n const data = await fs.promises.readFile(filePath);\n this.end(data);\n return;\n }\n\n // Explicit length so the engine skips chunked encoding for the stream.\n // (If the file shrinks mid-stream, the engine detects the short write at\n // end() and forces Connection: close - the client sees truncation, never\n // the next response's bytes as this body.)\n this.setHeader('Content-Length', String(stats.size));\n await new Promise<void>((resolve, reject) => {\n const stream = fs.createReadStream(filePath);\n streamRef = stream;\n let pendingResume: (() => void) | null = null;\n // ONE close listener for the stream's whole lifetime (not one per\n // backpressure pause), and it SETTLES the promise: a client abort\n // while the stream is paused must not leave `await sendFile()`\n // hanging forever.\n const onClose = () => {\n if (pendingResume) this.removeListener('drain', pendingResume);\n stream.destroy();\n resolve();\n };\n this.once('close', onClose);\n const cleanup = () => {\n this.removeListener('close', onClose);\n if (pendingResume) this.removeListener('drain', pendingResume);\n };\n stream.on('data', chunk => {\n if (this._ended) {\n cleanup();\n stream.destroy();\n resolve();\n return;\n }\n if (!this.write(chunk)) {\n stream.pause();\n pendingResume = () => {\n pendingResume = null;\n stream.resume();\n };\n this.once('drain', pendingResume);\n }\n });\n stream.on('end', () => {\n cleanup();\n this.end();\n resolve();\n });\n stream.on('error', (err: Error) => {\n cleanup();\n reject(err);\n });\n });\n } catch {\n // The head may already be on the wire (streaming branch). Terminate the\n // response so the client isn't left waiting on the declared\n // Content-Length, and tear down the read stream; only 404 if nothing was\n // sent yet.\n if (streamRef) streamRef.destroy();\n if (this.headersSent && !this._ended) {\n this.end();\n } else if (!this.headersSent && !this._ended) {\n this.status(404).json({ success: false, error: 'File not found' });\n }\n }\n }\n\n attachment(filename?: string) {\n if (this.headersSent) return this;\n if (filename) {\n const safeName = filename.replace(/[\\r\\n\"]/g, '');\n this.setHeader('Content-Disposition', `attachment; filename=\"${safeName}\"`);\n if (!this.getHeader('Content-Type')) {\n const dot = filename.lastIndexOf('.');\n if (dot !== -1) {\n this.setHeader('Content-Type', mimeTypeFor(filename.substring(dot)));\n }\n }\n } else {\n this.setHeader('Content-Disposition', 'attachment');\n }\n return this;\n }\n\n async download(filePath: string, filename?: string): Promise<void> {\n this.attachment(filename || filePath.split('/').pop());\n return this.sendFile(filePath);\n }\n\n format(handlers: Record<string, () => any | Promise<any>>): void {\n const types = Object.keys(handlers).filter(k => k !== 'default');\n const matched = this._moroReq ? this._moroReq.accepts(types) : false;\n const chosen = matched ? handlers[matched as string] : handlers.default;\n if (!chosen) {\n this.statusCode = 406;\n this.setHeader('Content-Type', 'text/plain; charset=utf-8');\n this.end('Not Acceptable');\n return;\n }\n this.vary('Accept');\n if (matched && typeof matched === 'string') {\n this.type(matched);\n }\n chosen();\n }\n\n // ==== Express-compatible response helpers (parity with the uWS adapter) ====\n\n set(field: string | Record<string, any>, value?: any) {\n if (this.headersSent) return this;\n if (typeof field === 'string') {\n if (value !== undefined) this.setHeader(field, value);\n } else {\n for (const key in field) {\n this.setHeader(key, field[key]);\n }\n }\n return this;\n }\n\n get(field: string) {\n return this.getHeader(field);\n }\n\n hasHeader(name: string): boolean {\n return this.getHeader(name) !== undefined;\n }\n\n setBulkHeaders(headers: Record<string, string | number>) {\n if (this.headersSent) return this;\n for (const key in headers) {\n this.setHeader(key, String(headers[key]));\n }\n return this;\n }\n\n appendHeader(name: string, value: string | string[]) {\n if (this.headersSent) return this;\n const lower = name.toLowerCase();\n const existing = this.responseHeaders[lower];\n if (existing) {\n const values = Array.isArray(existing) ? existing : [existing as string];\n const incoming = Array.isArray(value) ? value : [value];\n this.responseHeaders[lower] = values.concat(incoming);\n } else {\n this.responseHeaders[lower] = value;\n }\n return this;\n }\n\n append(field: string, value: string | string[]) {\n return this.appendHeader(field, value);\n }\n\n type(contentType: string) {\n if (this.headersSent) return this;\n let ct = contentType;\n if (ct.indexOf('/') === -1) {\n const shorthands: Record<string, string> = {\n json: 'application/json; charset=utf-8',\n html: 'text/html; charset=utf-8',\n text: 'text/plain; charset=utf-8',\n txt: 'text/plain; charset=utf-8',\n xml: 'application/xml',\n js: 'application/javascript',\n css: 'text/css; charset=utf-8',\n form: 'application/x-www-form-urlencoded',\n };\n ct = shorthands[ct.toLowerCase()] || `application/${ct}`;\n }\n this.setHeader('Content-Type', ct);\n return this;\n }\n\n sendStatus(code: number) {\n if (this.headersSent) return;\n this.statusCode = code;\n // Reason phrase when the code is known, otherwise the code itself\n // (Node behavior) - never a fabricated \"OK\" for a non-2xx status.\n const statusString = STATUS_STRINGS.get(code);\n const body = statusString ? statusString.slice(String(code).length + 1) : String(code);\n this.setHeader('Content-Type', 'text/plain; charset=utf-8');\n this.end(body);\n }\n\n location(url: string) {\n if (this.headersSent) return this;\n this.setHeader('Location', url.replace(/[\\r\\n]/g, ''));\n return this;\n }\n\n vary(field: string | string[]) {\n if (this.headersSent) return this;\n const existing = this.responseHeaders['vary'];\n const existingList = existing\n ? String(existing)\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n : [];\n const incoming = Array.isArray(field) ? field : [field];\n for (const f of incoming) {\n if (!existingList.some(e => e.toLowerCase() === f.toLowerCase())) {\n existingList.push(f);\n }\n }\n this.responseHeaders['vary'] = existingList.join(', ');\n return this;\n }\n\n links(links: Record<string, string>) {\n if (this.headersSent) return this;\n const parts: string[] = [];\n for (const rel in links) {\n parts.push(`<${links[rel]}>; rel=\"${rel}\"`);\n }\n if (parts.length > 0) {\n const existing = this.responseHeaders['link'];\n this.responseHeaders['link'] = existing\n ? `${existing}, ${parts.join(', ')}`\n : parts.join(', ');\n }\n return this;\n }\n\n canSetHeaders(): boolean {\n return !this.headersSent;\n }\n\n getResponseState() {\n return {\n headersSent: this.headersSent,\n statusCode: this.statusCode,\n headers: this.responseHeaders,\n finished: this._ended,\n writable: !this._ended,\n };\n }\n}\n\n/**\n * Moro Engine HTTP Server Adapter\n * Bridges @morojs/engine with Moro's HTTP abstractions. Duck-typed to the\n * same surface framework.ts/moro.ts use on UWebSocketsHttpServer.\n */\nexport class MoroEngineServer {\n /** @internal read by EngineRequest/EngineResponse for lazy fetchers */\n _engine: any;\n // Hot-path native functions hoisted off the loader's module Proxy: every\n // property access on the engine module runs its `get` trap (a Set probe +\n // binding load) that V8 cannot inline-cache. Hoisted once here, each\n // per-request native call becomes a plain monomorphic field load. The\n // functions are plain N-API exports with no `this` dependence.\n /** @internal */ _respond!: (\n reqId: number,\n status: number,\n headers: string[] | null,\n body: any\n ) => void;\n /** @internal */ _writeHead!: (reqId: number, status: number, headers: string[] | null) => void;\n /** @internal */ _write!: (reqId: number, chunk: any) => boolean;\n /** @internal */ _end!: (reqId: number, data?: any) => void;\n /** @internal */ _isAborted!: (reqId: number) => boolean;\n /** @internal */ _getQuery!: (reqId: number) => string | undefined;\n /** @internal */ _getHeaders!: (reqId: number) => string[] | undefined;\n /** @internal */ _getHeader!: (reqId: number, name: string) => string | undefined;\n /** @internal */ _getBody!: (reqId: number) => ArrayBuffer | null;\n /** @internal */ _getRemoteAddress!: (reqId: number) => string | undefined;\n /** @internal */ _getMethod!: (reqId: number) => string | undefined;\n /** @internal read by EngineRequest#protocol/socket.encrypted - true when the\n * engine is terminating TLS for this server (engine >= 1.2.0 + ssl passed) */\n isSsl = false;\n\n private serverId: number;\n private globalMiddleware: Middleware[] = [];\n private logger = createFrameworkLogger('EngineHttpServer');\n private hookManager: any;\n private requestCounter = 0;\n private requestTrackingEnabled = true; // Generate request IDs (read lazily by EngineRequest)\n private isListening = false;\n private port?: number;\n private host?: string;\n // In-flight responses by reqId so onAborted/onWritable reach the wrappers;\n // entries are dropped on terminal writes (_complete) and aborts\n private inflight = new Map<number, EngineResponse>();\n // Small stable handle exposed via getServer()/getApp() (observability only)\n private handle: any;\n // Set by the engine WebSocket adapter when WS support is enabled; when\n // present, upgrade requests are routed to the engine's native WS path.\n // onOpen receives the handshake request's remote address and headers -\n // captured before the upgrade invalidates the reqId - so IP-based WS\n // rate limiting and header/token connection auth see real values.\n private _wsBridge?: {\n onOpen(\n wsId: number,\n path: string,\n info?: { ip: string; headers: Record<string, string>; query?: string }\n ): void;\n onMessage(wsId: number, data: any, isBinary: boolean): void;\n onClose(wsId: number, code: number): void;\n };\n // Handshake info for the upgrade currently in flight: set just before\n // upgradeToWebSocket() (which fires onWsOpen synchronously), consumed there.\n private _pendingWsInfo?:\n { ip: string; headers: Record<string, string>; query: string } | undefined;\n\n // Body size limits (bytes) - configured from server.bodySizeLimit/maxUploadSize\n private maxBodySize: number = 10 * 1024 * 1024;\n private maxUploadSize: number = 100 * 1024 * 1024;\n private reusePort = false;\n private _capabilities?: EngineCapabilities;\n private _limits?: HttpRuntimeLimits;\n private _ssl?: Record<string, any>;\n private _http2Settings?: Http2ServerOptions;\n private multipartLimits?: MultipartLimits;\n /** @internal read by EngineResponse for buffered-response compression */\n _compression: CompressionSettings = {\n enabled: false,\n threshold: 1024,\n level: 6,\n encodings: ['br', 'gzip', 'deflate'],\n };\n // Set by close(); listen() then registers a fresh native server, because the\n // old serverId's uv handles are torn down and must never be reused.\n private closed = false;\n\n // Direct router dispatch (set from Moro.listen via setRouterHandler)\n private routerHandler?: (req: HttpRequest, res: HttpResponse) => boolean | Promise<boolean>;\n\n // Global error handler (Moro.setErrorHandler) - shapes errors thrown from\n // global middleware, hooks and body parsing (parity with MoroHttpServer)\n private errorHandler?: (err: any, req: HttpRequest, res: HttpResponse) => any | Promise<any>;\n\n // Direct route table (parity with MoroHttpServer): routes registered via\n // get/post/... - the framework's registerDirectRoutes() calls these. They\n // live here, independent of the UnifiedRouter singleton, so app.post()-style\n // routes keep working even if the unified router is reset (as the test\n // harness does between cases). Checked before the unified router in dispatch.\n private directRoutes: Array<{\n method: string;\n pattern: RegExp;\n paramNames: string[];\n handlers: Array<Middleware | HttpHandler>;\n }> = [];\n\n constructor(\n options: {\n /** Normalized SSL config projected for the engine (both shapes). */\n ssl?: Record<string, any> | null;\n /** Engine feature flags (from loadNativeEngine) - gates the ssl/http2/\n * limit options so we never pass a key an older engine won't parse. */\n capabilities?: EngineCapabilities;\n /** Flattened runtime limits (bytes/ms) from the framework. */\n limits?: HttpRuntimeLimits;\n /** HTTP/2 settings when serving ALPN h2 natively (engine caps.http2). */\n http2Settings?: Http2ServerOptions;\n maxBodySize?: number;\n maxUploadSize?: number;\n /** Preloaded native engine module (from loadNativeEngine) - avoids a\n * second resolution and keeps load failures at the framework's\n * synchronous preflight instead of surfacing at listen() */\n engineModule?: any;\n /** Bind with SO_REUSEPORT so cluster workers can share the port\n * (POSIX only; the framework gates Windows clustering to Node) */\n reusePort?: boolean;\n } = {}\n ) {\n if (options.maxBodySize) this.maxBodySize = options.maxBodySize;\n if (options.maxUploadSize) this.maxUploadSize = options.maxUploadSize;\n this.reusePort = options.reusePort === true;\n if (options.capabilities) this._capabilities = options.capabilities;\n if (options.limits) this._limits = options.limits;\n if (options.ssl) this._ssl = options.ssl;\n if (options.http2Settings) this._http2Settings = options.http2Settings;\n if (options.limits?.multipart) this.multipartLimits = options.limits.multipart;\n\n // The framework preloads the engine synchronously (loadNativeEngine) and\n // injects it; loading here directly covers standalone construction.\n const engineModule = options.engineModule ?? loadNativeEngine()?.module;\n if (!engineModule) {\n throw new Error(\n 'No native HTTP engine available: ' +\n (getNativeEngineLoadErrors().join('; ') || 'not installed')\n );\n }\n const surface = engineModule.default || engineModule;\n if (typeof surface.serve !== 'function' || typeof surface.respond !== 'function') {\n throw new Error(\n 'Engine module does not provide the @morojs/engine API (serve/respond) - ' +\n 'use UWebSocketsHttpServer for uWS-style modules'\n );\n }\n this._engine = surface;\n this._respond = surface.respond;\n this._writeHead = surface.writeHead;\n this._write = surface.write;\n this._end = surface.end;\n this._isAborted = surface.isAborted;\n this._getQuery = surface.getQuery;\n this._getHeaders = surface.getHeaders;\n this._getHeader = surface.getHeader;\n this._getBody = surface.getBody;\n this._getRemoteAddress = surface.getRemoteAddress;\n this._getMethod = surface.getMethod;\n\n // TLS: pass it through when the engine supports it; otherwise keep the\n // (now capability-gated) warning so a proxy/node fallback is clear.\n if (this._ssl && this._capabilities?.tls) {\n this.isSsl = true; // req.secure/protocol now report https\n } else if (this._ssl && !this._capabilities?.tls) {\n this.logger.warn(\n 'This @morojs/engine build does not terminate TLS - terminate at a ' +\n \"proxy, upgrade the engine, or set engine: 'node' for in-process HTTPS\",\n 'Init'\n );\n }\n\n // Register callbacks now - the engine opens sockets only at listen().\n this.serverId = this.registerWithEngine();\n\n // Framework observability handle exposed via getServer()/getApp(). It\n // mimics enough of a net.Server that code reaching for the raw server\n // (e.g. `app.core.httpServer.getServer().close(cb)`) works on the engine\n // path too - address() is null until listening, and close(cb) forwards to\n // the adapter's shutdown so callers never hang waiting on a missing method.\n this.handle = Object.defineProperties(\n {\n engine: '@morojs/engine',\n address: () =>\n this.isListening\n ? { address: this.host || '0.0.0.0', family: 'IPv4', port: this.port || 0 }\n : null,\n close: (cb?: (err?: Error) => void) => {\n this.close(cb);\n return this.handle;\n },\n },\n {\n serverId: { get: () => this.serverId, enumerable: true },\n listening: { get: () => this.isListening, enumerable: true },\n }\n );\n\n this.logger.info('Moro engine HTTP server created', 'Init');\n }\n\n /** @internal terminal write/abort cleanup - drops the reqId mapping */\n _complete(reqId: number): void {\n this.inflight.delete(reqId);\n }\n\n // Register callbacks + limits with the native engine, returning the new\n // serverId. Called from the constructor and again by listen() after a\n // close() (the old native server is gone; a restart needs a fresh one).\n // The engine buffers bodies natively and 413s over its limit; it cannot\n // see content types, so it gets the larger upload limit and parseBody\n // enforces the tighter non-multipart limit (mirrors the other servers).\n //\n // Every option beyond maxBodySize/reusePort is gated on engine capabilities\n // so this never hands a key an older engine build cannot parse (an unknown\n // option would just be ignored, but gating keeps the intent explicit).\n private registerWithEngine(): number {\n const caps = this._capabilities;\n const limits = this._limits;\n const t = limits?.timeouts ?? {};\n const serveOptions: Record<string, any> = {\n maxBodySize: Math.max(this.maxBodySize, this.maxUploadSize),\n reusePort: this.reusePort,\n };\n // Timeouts + connection cap: understood since the engine's first release.\n if (t.idle !== undefined) serveOptions.idleTimeoutMs = t.idle;\n if (t.request !== undefined) serveOptions.requestTimeoutMs = t.request;\n if (limits?.maxConnections && limits.maxConnections > 0) {\n serveOptions.maxConnections = limits.maxConnections;\n }\n if (limits?.maxPendingBytes !== undefined) {\n serveOptions.maxPendingBytes = limits.maxPendingBytes;\n }\n // Full limit surface (engine >= 1.1.0).\n if (caps?.limits) {\n if (limits?.maxHeaderSize !== undefined) serveOptions.maxHeadSize = limits.maxHeaderSize;\n if (limits?.maxHeaders !== undefined) serveOptions.maxHeaders = limits.maxHeaders;\n if (limits?.wsMaxMessageSize !== undefined)\n serveOptions.wsMaxMessageSize = limits.wsMaxMessageSize;\n if (limits?.wsBackpressureLimit !== undefined)\n serveOptions.wsBackpressureLimit = limits.wsBackpressureLimit;\n if (limits?.writeHighWaterMark !== undefined)\n serveOptions.writeHighWaterMark = limits.writeHighWaterMark;\n if (limits?.backlog !== undefined) serveOptions.backlog = limits.backlog;\n }\n // TLS: gated on the engine's own capability flag (caps.tls), not a version\n // number, so a mismatched engine build is never handed an ssl option it\n // can't parse.\n if (caps?.tls && this._ssl) {\n serveOptions.ssl = this._ssl;\n }\n // HTTP/2: likewise gated on caps.http2.\n if (caps?.http2 && this._http2Settings) {\n serveOptions.http2 = {\n ...(this._http2Settings.settings ?? {}),\n };\n }\n return this._engine.serve(\n {\n onRequest: (reqId: number, methodIdx: number, path: string) =>\n this.onRequest(reqId, methodIdx, path),\n onAborted: (reqId: number) => this.onAborted(reqId),\n onWritable: (reqId: number) => this.onWritable(reqId),\n onWsOpen: (wsId: number, path: string) =>\n this._wsBridge?.onOpen(wsId, path, this._pendingWsInfo),\n onWsMessage: (wsId: number, data: any, isBinary: boolean) =>\n this._wsBridge?.onMessage(wsId, data, isBinary),\n onWsClose: (wsId: number, code: number) => this._wsBridge?.onClose(wsId, code),\n },\n serveOptions\n );\n }\n\n // ---- WebSocket bridge (used by EngineWebSocketAdapter) ----\n\n /** Register the engine WebSocket bridge; upgrade requests then route natively. */\n enableWebSocket(bridge: {\n onOpen(wsId: number, path: string): void;\n onMessage(wsId: number, data: any, isBinary: boolean): void;\n onClose(wsId: number, code: number): void;\n }): void {\n this._wsBridge = bridge;\n }\n\n /** Send a frame on a WebSocket. Returns false on backpressure. */\n wsSend(wsId: number, data: string | ArrayBuffer | Buffer, isBinary: boolean): boolean {\n return this._engine.wsSend(wsId, data, isBinary) !== false;\n }\n\n /** Close a WebSocket (RFC 6455 close frame). */\n wsClose(wsId: number, code?: number, reason?: string): void {\n this._engine.wsClose(wsId, code, reason);\n }\n\n // Direct router dispatch - called after global middleware without the\n // per-middleware promise machinery (mirrors MoroHttpServer.setRouterHandler)\n setRouterHandler(fn: (req: HttpRequest, res: HttpResponse) => boolean | Promise<boolean>): void {\n this.routerHandler = fn;\n }\n\n // Register a global error handler (called from Moro.setErrorHandler)\n setErrorHandler(fn: (err: any, req: HttpRequest, res: HttpResponse) => any | Promise<any>): void {\n this.errorHandler = fn;\n }\n\n // Request/response decorations (app.decorateRequest/decorateReply). Applied\n // per request/response since EngineRequest/EngineResponse are shared classes\n // (decorating their prototype would leak across apps in one process). Empty\n // by default, so the common path pays only a `> 0` length check.\n private requestDecorationKeys: string[] = [];\n private requestDecorations: Record<string, any> = {};\n private responseDecorationKeys: string[] = [];\n private responseDecorations: Record<string, any> = {};\n\n setRequestDecorations(decorations: Record<string, any>): void {\n this.requestDecorations = decorations;\n this.requestDecorationKeys = Object.keys(decorations);\n }\n\n setResponseDecorations(decorations: Record<string, any>): void {\n this.responseDecorations = decorations;\n this.responseDecorationKeys = Object.keys(decorations);\n }\n\n // Direct route registration (mirrors MoroHttpServer). The framework's\n // registerDirectRoutes() invokes these as httpServer[method](path, handler).\n private addDirectRoute(\n method: string,\n path: string,\n handlers: Array<Middleware | HttpHandler>\n ): void {\n const compiled = PathMatcher.compile(path);\n const pattern =\n compiled.pattern || new RegExp(`^${(path.split('?')[0] ?? '').replace(/\\//g, '\\\\/')}$`);\n this.directRoutes.push({ method, pattern, paramNames: compiled.paramNames, handlers });\n }\n\n get(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('GET', path, handlers);\n }\n post(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('POST', path, handlers);\n }\n put(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('PUT', path, handlers);\n }\n delete(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('DELETE', path, handlers);\n }\n patch(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('PATCH', path, handlers);\n }\n options(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('OPTIONS', path, handlers);\n }\n head(path: string, ...handlers: Array<Middleware | HttpHandler>): void {\n this.addDirectRoute('HEAD', path, handlers);\n }\n\n // Match + run a direct route. Returns true if one handled the request.\n private async dispatchDirectRoute(\n httpReq: EngineRequest,\n httpRes: EngineResponse\n ): Promise<boolean> {\n if (this.directRoutes.length === 0) return false;\n const method = httpReq.method;\n const path = httpReq.path;\n for (const route of this.directRoutes) {\n if (route.method !== method) continue;\n const matches = path.match(route.pattern);\n if (!matches) continue;\n\n if (route.paramNames.length > 0) {\n const params: Record<string, string> = {};\n for (let i = 0; i < route.paramNames.length; i++) {\n const paramName = route.paramNames[i];\n if (paramName === undefined) continue;\n const raw = matches[i + 1];\n if (raw === undefined) {\n params[paramName] = '';\n } else {\n // Malformed escapes (e.g. /users/%zz) keep the raw text - a\n // URIError here would turn an odd URL into a 500\n try {\n params[paramName] = decodeURIComponent(raw);\n } catch {\n params[paramName] = raw;\n }\n }\n }\n httpReq.params = { ...httpReq.params, ...params };\n }\n\n // Run the handler chain: middleware-style (req,res,next) links run in\n // order; the final handler's return value (if any) is sent as JSON.\n for (let i = 0; i < route.handlers.length; i++) {\n if (httpRes.headersSent) break;\n const handler = route.handlers[i] as any;\n const isLast = i === route.handlers.length - 1;\n if (isLast) {\n const result = handler(httpReq as any, httpRes as any);\n const value = result && typeof result.then === 'function' ? await result : result;\n if (value !== undefined && !httpRes.headersSent) {\n (httpRes as any).json(value);\n }\n } else {\n await new Promise<void>((resolve, reject) => {\n let settled = false;\n const done = (err?: Error) => {\n if (settled) return;\n settled = true;\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n };\n try {\n const r = handler(httpReq as any, httpRes as any, done);\n if (r && typeof r.then === 'function') {\n r.then(() => done(), done);\n } else if (httpRes.headersSent) {\n // A middleware that ended the response without calling next()\n // would otherwise leave this await unresolved - unblock the chain.\n done();\n }\n } catch (e) {\n done(e as Error);\n }\n });\n }\n }\n return true;\n }\n return false;\n }\n\n // The engine has no native route table - every request already reaches the\n // unified router through a single onRequest callback with zero middleware\n // machinery, so there is no fast path to register. Accepted for interface\n // parity with the uWS adapter.\n setNativeRouteProvider(_provider: () => Array<any>, _onError?: (...args: any[]) => any): void {\n this.logger.debug(\n 'Native route provider noted (engine dispatch is already direct)',\n 'NativeRoutes'\n );\n }\n\n private onRequest(reqId: number, methodIdx: number, path: string): void {\n // WebSocket upgrade: when a WS bridge is registered and this is an upgrade\n // request, hand the connection to the engine's native WS path. The engine\n // sends the 101 handshake and drives onWsOpen/Message/Close.\n if (this._wsBridge) {\n const upgrade = this._getHeader(reqId, 'upgrade');\n if (upgrade && upgrade.toLowerCase() === 'websocket') {\n // Snapshot handshake data now - the upgrade invalidates the reqId,\n // after which these fetchers return empty values.\n const ip: string = this._getRemoteAddress(reqId) || '';\n const headers: Record<string, string> = {};\n const flat: string[] | undefined = this._getHeaders(reqId);\n if (flat) {\n // Join duplicates exactly like the EngineRequest.headers getter -\n // last-wins would let a client send two X-Forwarded-For lines and\n // hide the earlier one from IP-based WS auth / rate-limiting.\n for (let i = 0; i + 1 < flat.length; i += 2) {\n const key = flat[i];\n const val = flat[i + 1];\n if (key === undefined || val === undefined) continue;\n const existing = headers[key];\n headers[key] =\n existing === undefined ? val : existing + (key === 'cookie' ? '; ' : ', ') + val;\n }\n }\n // Capture the query string too (invalidated by the upgrade like the\n // rest), so handlers can read handshake query params (e.g. orgId).\n const query: string = this._getQuery(reqId) || '';\n this._pendingWsInfo = { ip, headers, query };\n const wsId = this._engine.upgradeToWebSocket(reqId);\n this._pendingWsInfo = undefined;\n if (wsId !== -1) return; // WS took over this connection\n // else: not a valid upgrade - fall through to normal HTTP handling\n }\n }\n\n // methodIdx 7 (OTHER) needs the extra crossing; the seven common methods\n // resolve from the static table\n const method = (\n methodIdx === 7 ? this._getMethod(reqId) || 'OTHER' : METHODS[methodIdx]\n ) as string;\n\n const httpReq = new EngineRequest(this, reqId, method, path);\n const httpRes = new EngineResponse(this, reqId, this.logger);\n httpRes._moroReq = httpReq;\n\n // Apply app.decorateRequest/decorateReply values (rare; opt-in)\n if (this.requestDecorationKeys.length > 0) {\n for (const key of this.requestDecorationKeys) {\n (httpReq as any)[key] = this.requestDecorations[key];\n }\n }\n if (this.responseDecorationKeys.length > 0) {\n for (const key of this.responseDecorationKeys) {\n (httpRes as any)[key] = this.responseDecorations[key];\n }\n }\n\n this.requestCounter++;\n\n // SYNC FAST PATH (parity with MoroHttpServer's handleRequest split): with\n // no body to parse, no request/response hooks and no global middleware,\n // the router dispatch runs synchronously in this frame - the async\n // handleRequest below would allocate a promise + async context per\n // request only to reach zero awaits. Only the framework's own frame is\n // de-asynced: an async route handler still returns its promise through\n // the router and is driven to completion here.\n const hookManager = this.hookManager;\n const hooksActive =\n hookManager &&\n (hookManager.hasHooks === undefined ||\n hookManager.hasHooks('request') ||\n hookManager.hasHooks('response'));\n const needsBody =\n method.charCodeAt(0) === 80 && // 'P' char code\n (method === 'POST' || method === 'PUT' || method === 'PATCH');\n\n if (!needsBody && !hooksActive && this.globalMiddleware.length === 0 && this.routerHandler) {\n let handled: boolean | Promise<boolean> = true;\n try {\n handled = this.routerHandler(httpReq as any as HttpRequest, httpRes as any as HttpResponse);\n } catch (error) {\n // Error path owns the response from here (handled stays true)\n void this.handleDispatchError(error, httpReq, httpRes);\n }\n if (handled !== true) {\n if (handled && typeof (handled as any).then === 'function') {\n (handled as Promise<boolean>).then(\n ok => {\n if (!ok) void this.finishUnrouted(httpReq, httpRes);\n },\n error => void this.handleDispatchError(error, httpReq, httpRes)\n );\n } else {\n // Sync miss from the router - direct-route fallback, then 404\n void this.finishUnrouted(httpReq, httpRes);\n }\n }\n } else {\n void this.handleRequest(httpReq, httpRes);\n }\n\n // Register for onAborted/onWritable routing only when the response is\n // still in flight after the synchronous dispatch window. Sync handlers\n // have already ended by here, and the engine never fires those callbacks\n // for a completed reqId - registering every request just churns this\n // long-lived Map's old-space backing store, and entries alive at a\n // scavenge promote the whole request/response graph (at ~570k pipelined\n // req/s that meant full GCs every ~400ms and a ~150 MB heap vs ~30 MB).\n if (!httpRes.writableEnded) {\n httpRes._registered = true;\n this.inflight.set(reqId, httpRes);\n }\n }\n\n private onAborted(reqId: number): void {\n const httpRes = this.inflight.get(reqId);\n if (httpRes) {\n this.inflight.delete(reqId);\n httpRes._handleAbort();\n }\n }\n\n private onWritable(reqId: number): void {\n const httpRes = this.inflight.get(reqId);\n if (httpRes) httpRes._handleWritable();\n }\n\n // Router-miss continuation shared by the sync fast path: direct-route\n // fallback, then 404 - with the same error shaping as handleRequest.\n private async finishUnrouted(httpReq: EngineRequest, httpRes: EngineResponse): Promise<void> {\n try {\n if (await this.dispatchDirectRoute(httpReq, httpRes)) return;\n if (!httpRes.headersSent && !httpRes.writableEnded) {\n httpRes.statusCode = 404;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Not found\"}');\n }\n } catch (error) {\n await this.handleDispatchError(error, httpReq, httpRes);\n }\n }\n\n private async handleRequest(httpReq: EngineRequest, httpRes: EngineResponse): Promise<void> {\n try {\n const method = httpReq.method;\n\n // Parse body only for body methods (all start with 'P'). The engine\n // buffered the body before onRequest fired, so this is synchronous.\n if (\n method.charCodeAt(0) === 80 && // 'P' char code\n (method === 'POST' || method === 'PUT' || method === 'PATCH')\n ) {\n this.parseBody(httpReq);\n }\n\n // Execute hooks before request processing - skipped entirely when none registered\n const hookManager = this.hookManager;\n if (hookManager && (hookManager.hasHooks === undefined || hookManager.hasHooks('request'))) {\n await hookManager.execute('request', {\n request: httpReq,\n response: httpRes,\n });\n }\n\n // Post-response hooks (session persistence, auth session refresh, CDN\n // invalidation) run after the response is flushed, off the critical path.\n if (hookManager && (hookManager.hasHooks === undefined || hookManager.hasHooks('response'))) {\n httpRes.once('finish', () => {\n void Promise.resolve(\n 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 // 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 chain\n if (this.globalMiddleware.length > 0) {\n await this.executeMiddleware(\n this.globalMiddleware,\n httpReq as any as HttpRequest,\n httpRes as any as HttpResponse\n );\n if (httpRes.headersSent) return;\n }\n\n // Unified router first - it carries the full route feature set\n // (per-route middleware, validation, auth, ...). The direct route table\n // below is only a fallback for when the unified router singleton was\n // reset out from under a listening app (as the test harness does), so it\n // must never shadow the richer unified-router path.\n const routerHandler = this.routerHandler;\n if (routerHandler) {\n const handled = routerHandler(\n httpReq as any as HttpRequest,\n httpRes as any as HttpResponse\n );\n if (handled) {\n if (typeof (handled as any).then === 'function') {\n if (await handled) return;\n } else {\n return;\n }\n }\n }\n\n // Direct route table fallback (parity with node's dual registration -\n // survives a UnifiedRouter reset)\n if (await this.dispatchDirectRoute(httpReq, httpRes)) return;\n\n // No route matched\n if (!httpRes.headersSent && !httpRes.writableEnded) {\n httpRes.statusCode = 404;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Not found\"}');\n }\n } catch (error) {\n await this.handleDispatchError(error, httpReq, httpRes);\n }\n }\n\n // Error shaping shared by the async pipeline and the sync fast path:\n // 413/400 client responses, error hooks, the app's error handler, then 500.\n private async handleDispatchError(\n error: unknown,\n httpReq: EngineRequest,\n httpRes: EngineResponse\n ): Promise<void> {\n {\n // Payload-too-large: respond 413 rather than a generic 500\n if ((error as any)?.statusCode === 413 && !httpRes.writableEnded && !httpRes.headersSent) {\n httpRes.statusCode = 413;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Request entity too large\"}');\n return;\n }\n\n // Malformed body (parseBody): a client error, not a server error\n if ((error as any)?.statusCode === 400 && !httpRes.writableEnded && !httpRes.headersSent) {\n httpRes.statusCode = 400;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Invalid request body\"}');\n return;\n }\n\n this.logger.error(\n `Request handling error: ${error instanceof Error ? error.message : String(error)}`,\n 'RequestError'\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 const errorHooks = this.hookManager;\n if (errorHooks && (errorHooks.hasHooks === undefined || errorHooks.hasHooks('error'))) {\n void Promise.resolve(\n errorHooks.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 // The app's global error handler (Moro.setErrorHandler) gets first shot\n // at shaping the response - same contract as the Node server.\n if (this.errorHandler && !httpRes.writableEnded && !httpRes.headersSent) {\n try {\n await this.errorHandler(\n error,\n httpReq as any as HttpRequest,\n httpRes as any as HttpResponse\n );\n if (httpRes.headersSent || httpRes.writableEnded) return;\n } catch (handlerError) {\n this.logger.error(\n `Error handler threw: ${handlerError instanceof Error ? handlerError.message : String(handlerError)}`,\n 'ErrorHandler'\n );\n }\n }\n\n // Send error response if not already sent\n if (!httpRes.writableEnded && !httpRes.headersSent) {\n try {\n httpRes.statusCode = 500;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end('{\"success\":false,\"error\":\"Internal server error\"}');\n } catch {\n this.logger.error('Failed to send error response', 'ResponseError');\n }\n }\n }\n }\n\n // Parse the engine-buffered body (JSON/urlencoded/multipart/text - identical\n // semantics to the Node and uWS servers' readBody). getBody returns a STABLE\n // ArrayBuffer copy, so Buffer.from() views it with no aliasing hazard.\n private parseBody(httpReq: EngineRequest): void {\n const raw: ArrayBuffer | null = this._getBody(httpReq._reqId);\n if (!raw || raw.byteLength === 0) return;\n\n const contentType = httpReq.headers['content-type'] || '';\n const isMultipart = contentType.includes('multipart/form-data');\n const maxSize = isMultipart ? this.maxUploadSize : this.maxBodySize;\n\n // The engine natively enforces the larger of the two limits; the tighter\n // non-multipart limit is enforced here (responds 413 via handleRequest)\n if (raw.byteLength > maxSize) {\n const error: any = new Error(\n isMultipart ? 'File upload too large' : 'Request body too large'\n );\n error.statusCode = 413;\n throw error;\n }\n\n const buffer = Buffer.from(raw);\n\n try {\n if (contentType.includes('application/json')) {\n httpReq.body = JSON.parse(buffer.toString('utf-8'));\n } else if (contentType.includes('application/x-www-form-urlencoded')) {\n const params = new URLSearchParams(buffer.toString('utf-8'));\n const body: Record<string, any> = {};\n params.forEach((value, key) => {\n body[key] = value;\n });\n httpReq.body = body;\n } else if (isMultipart) {\n // Shared parser (same as the Node/uWS servers) - stringifying\n // multipart would corrupt binary uploads and lose fields/files\n httpReq.body = parseMultipartBuffer(buffer, contentType, this.multipartLimits);\n } else {\n httpReq.body = buffer.toString('utf-8');\n }\n } catch (parseError) {\n // A limit error (multipart maxParts/maxFiles/maxFileSize) carries its own\n // 413 - preserve it rather than masking it as a generic 400 malformed.\n if (parseError && typeof (parseError as any).statusCode === 'number') {\n throw parseError;\n }\n // A malformed body must fail the request (Node-path parity), not slip a\n // silent `body = null` past handlers that then treat it as \"no input\".\n const error: any = new Error(\n `Invalid request body: ${parseError instanceof Error ? parseError.message : String(parseError)}`\n );\n error.statusCode = 400;\n throw error;\n }\n }\n\n private async executeMiddleware(\n middleware: Middleware[],\n req: HttpRequest,\n res: HttpResponse\n ): Promise<void> {\n // Express error semantics: a middleware that calls next(err) (or throws)\n // routes to the NEXT 4-arg error handler (err, req, res, next), skipping\n // the normal 3-arg middleware in between; normal middleware is skipped\n // while an error is pending, and error handlers are skipped when there is\n // no error. An uncaught error propagates to handleRequest's 500 path.\n let error: any = null;\n for (const mw of middleware) {\n if (res.headersSent) break;\n const isErrorHandler = (mw as any).length >= 4;\n if (error && !isErrorHandler) continue;\n if (!error && isErrorHandler) continue;\n\n try {\n await new Promise<void>((resolve, reject) => {\n const next = (err?: any) => (err ? reject(err) : resolve());\n try {\n const result = error ? (mw as any)(error, req, res, next) : mw(req, res, next);\n if (result && typeof result.then === 'function') {\n result.then(() => resolve(), reject);\n }\n } catch (e) {\n reject(e);\n }\n });\n error = null; // handler (error or normal) completed cleanly\n } catch (e) {\n error = e; // route to the next error handler\n }\n }\n if (error) throw error;\n }\n\n // Public API - matches MoroHttpServer/UWebSocketsHttpServer interface\n\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 // Configure request tracking (ID generation)\n setRequestTracking(enabled: boolean): void {\n this.requestTrackingEnabled = enabled;\n }\n\n // Note: Route registration methods (get, post, etc.) are not used by the\n // engine adapter - all routing is handled by UnifiedRouter via setRouterHandler\n // (same as the uWS adapter)\n\n setHookManager(hookManager: any): void {\n this.hookManager = hookManager;\n }\n\n configurePerformance(config: any): void {\n // The engine's request hot path is batched natively; the one thing it\n // does NOT do itself is response compression, so wire that here (parity\n // with the Node path). Buffered responses only - streaming stays raw.\n this._compression = resolveCompressionSettings(config);\n this.logger.debug(\n `Performance configured (compression ${this._compression.enabled ? 'on' : 'off'})`,\n 'Config'\n );\n }\n\n listen(port: number, callback?: () => void): void;\n listen(port: number, host: string, callback?: () => void): void;\n listen(port: number, hostOrCallback?: string | (() => void), callback?: () => void): void {\n if (this.isListening) {\n this.logger.warn('Server is already listening', 'Listen');\n return;\n }\n\n const host = typeof hostOrCallback === 'string' ? hostOrCallback : '0.0.0.0';\n const cb = typeof hostOrCallback === 'function' ? hostOrCallback : callback;\n\n try {\n // listen() after close(): the old native server's handles are torn\n // down (its serverId is dead) - register a fresh one, like a Node\n // http.Server supports close() -> listen() cycles.\n if (this.closed) {\n this.serverId = this.registerWithEngine();\n this.closed = false;\n }\n // Synchronous bind; throws on bind errors, returns the actual port\n // (meaningful when port 0 asks for an ephemeral one)\n const actualPort = this._engine.listen(this.serverId, host, port);\n this.port = typeof actualPort === 'number' ? actualPort : port;\n this.host = host;\n this.isListening = true;\n this.logger.info(`Moro engine HTTP server listening on ${host}:${this.port}`, 'Listen');\n if (cb) cb();\n } catch (error) {\n this.logger.error(\n `Failed to listen on port ${port}: ${error instanceof Error ? error.message : String(error)}`,\n 'Listen'\n );\n throw error;\n }\n }\n\n /** Bounded drain window for in-flight responses during close() */\n private static readonly CLOSE_DRAIN_MS = 2000;\n\n close(callback?: (error?: Error) => void): void {\n if (!this.isListening) {\n if (callback) callback();\n return;\n }\n\n try {\n this.isListening = false;\n this.closed = true;\n\n // Graceful shutdown: stop accepting first, give in-flight responses a\n // bounded window to finish, then tear down. Requests still open at\n // teardown get onAborted -> 'close' events, so SSE intervals/monitors\n // registered on req.on('close') are released, not leaked.\n // Middleware is intentionally kept: close() -> listen() must serve with\n // the same cors/auth/compression stack (Node http.Server parity).\n if (typeof this._engine.stopListening === 'function') {\n this._engine.stopListening(this.serverId);\n }\n\n const finish = () => {\n try {\n this._engine.close(this.serverId);\n } catch (error) {\n this.logger.error('Error closing server', 'Close', {\n error: error instanceof Error ? error.message : String(error),\n });\n if (callback) callback(error instanceof Error ? error : new Error(String(error)));\n return;\n }\n this.inflight.clear();\n this.logger.info('Moro engine HTTP server closed', 'Close');\n if (callback) {\n // Give the event loop time to process the engine's socket teardown\n // before invoking the callback (matches the uWS adapter)\n setTimeout(() => {\n callback();\n }, 50);\n }\n };\n\n if (this.inflight.size === 0) {\n finish();\n return;\n }\n const deadline = Date.now() + MoroEngineServer.CLOSE_DRAIN_MS;\n const poll = setInterval(() => {\n if (this.inflight.size === 0 || Date.now() >= deadline) {\n clearInterval(poll);\n finish();\n }\n }, 25);\n // The drain poll must never keep the process alive by itself\n (poll as any).unref?.();\n } catch (error) {\n this.logger.error('Error closing server', 'Close', {\n error: error instanceof Error ? error.message : String(error),\n });\n if (callback) callback(error instanceof Error ? error : new Error(String(error)));\n }\n }\n\n getServer(): any {\n // Stable observability handle (listening/address) - there is no app object\n return this.handle;\n }\n\n getApp(): any {\n return this.handle;\n }\n\n forceCleanup(): void {\n // Cleanup method for compatibility\n this.logger.debug('Force cleanup called', 'Cleanup');\n }\n}\n"]}
|