@fluojs/platform-fastify
Advanced tools
+22
-8
@@ -220,3 +220,3 @@ import { Transform } from 'node:stream'; | ||
| raw: request.raw, | ||
| requestId: resolvePrimaryRequestIdFromHeaders(request.raw.headers), | ||
| requestId: resolveRequestIdFromHeaders(request.raw.headers), | ||
| signal: lazySignal.signal, | ||
@@ -567,3 +567,3 @@ url: urlParts.path + urlParts.search | ||
| raw: request.raw, | ||
| requestId: resolvePrimaryRequestIdFromHeaders(headerSnapshot), | ||
| requestId: resolveRequestIdFromHeaders(headerSnapshot), | ||
| signal, | ||
@@ -751,6 +751,2 @@ url: urlParts.path + urlParts.search | ||
| } | ||
| function resolvePrimaryRequestIdFromHeaders(headers) { | ||
| const requestId = headers['x-request-id']; | ||
| return Array.isArray(requestId) ? requestId[0] : requestId; | ||
| } | ||
| function createFastifyApp(httpsOptions, maxBodySize) { | ||
@@ -786,4 +782,10 @@ if (httpsOptions) { | ||
| const capture = new Transform({ | ||
| transform(chunk, _encoding, callback) { | ||
| const bufferChunk = Buffer.isBuffer(chunk) ? chunk : chunk instanceof Uint8Array ? Buffer.from(chunk) : Buffer.from(String(chunk), 'utf8'); | ||
| transform(chunk, encoding, callback) { | ||
| let bufferChunk; | ||
| try { | ||
| bufferChunk = createRawBodyBufferChunk(chunk, encoding); | ||
| } catch (error) { | ||
| callback(error instanceof Error ? error : new Error(String(error))); | ||
| return; | ||
| } | ||
| chunks.push(bufferChunk); | ||
@@ -807,2 +809,14 @@ capture.receivedEncodedLength += bufferChunk.byteLength; | ||
| } | ||
| function createRawBodyBufferChunk(chunk, encoding) { | ||
| if (Buffer.isBuffer(chunk)) { | ||
| return chunk; | ||
| } | ||
| if (chunk instanceof Uint8Array) { | ||
| return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength); | ||
| } | ||
| if (typeof chunk === 'string') { | ||
| return Buffer.from(chunk, encoding); | ||
| } | ||
| throw new TypeError(`Fastify raw-body capture received unsupported ${typeof chunk} stream chunk.`); | ||
| } | ||
| function isMultipartRequestContentType(contentType) { | ||
@@ -809,0 +823,0 @@ const primaryValue = Array.isArray(contentType) ? contentType[0] : contentType; |
+4
-4
@@ -11,3 +11,3 @@ { | ||
| ], | ||
| "version": "1.0.7", | ||
| "version": "1.0.8", | ||
| "private": false, | ||
@@ -42,4 +42,4 @@ "license": "MIT", | ||
| "fastify-raw-body": "^5.0.0", | ||
| "@fluojs/http": "^1.1.1", | ||
| "@fluojs/runtime": "^1.1.7" | ||
| "@fluojs/http": "^1.1.2", | ||
| "@fluojs/runtime": "^1.1.8" | ||
| }, | ||
@@ -49,3 +49,3 @@ "devDependencies": { | ||
| "@fluojs/di": "^1.1.0", | ||
| "@fluojs/testing": "^1.0.5" | ||
| "@fluojs/testing": "^1.0.6" | ||
| }, | ||
@@ -52,0 +52,0 @@ "scripts": { |
+1
-1
@@ -152,3 +152,3 @@ # @fluojs/platform-fastify | ||
| - `createFastifyAdapter(options)`: Fastify 어댑터를 위한 권장 팩토리입니다. | ||
| - `createFastifyAdapter(options, multipartOptions?)`: Fastify 어댑터를 위한 권장 팩토리입니다. 선택적 두 번째 인자는 직접 어댑터를 생성할 때 `maxFileSize`, `maxFiles`, `maxTotalSize` 같은 multipart 제한을 설정합니다. | ||
| - `bootstrapFastifyApplication(module, options)`: 암시적 리스닝 없이 수행하는 고급 부트스트랩입니다. | ||
@@ -155,0 +155,0 @@ - `runFastifyApplication(module, options)`: 생명주기 관리를 포함한 빠른 시작 헬퍼입니다. timeout/실패 시에는 해당 상태를 로그와 `process.exitCode`로 보고하고, 최종 프로세스 종료는 주변 호스트에 맡깁니다. |
+1
-1
@@ -152,3 +152,3 @@ # @fluojs/platform-fastify | ||
| - `createFastifyAdapter(options)`: Recommended factory for the Fastify adapter. | ||
| - `createFastifyAdapter(options, multipartOptions?)`: Recommended factory for the Fastify adapter. The optional second argument configures multipart limits such as `maxFileSize`, `maxFiles`, and `maxTotalSize` for direct adapter construction. | ||
| - `bootstrapFastifyApplication(module, options)`: advanced bootstrap without implicit listening. | ||
@@ -155,0 +155,0 @@ - `runFastifyApplication(module, options)`: Quick-start helper with lifecycle management. On timeout/failure it reports the condition through logging and `process.exitCode`, while leaving final process termination to the surrounding host. |
65926
0.98%1060
1.34%Updated
Updated