@fluojs/platform-fastify 1.0.6 → 1.0.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/README.ko.md +1 -1
- package/README.md +1 -1
- package/dist/adapter.js +24 -10
- package/package.json +4 -4
package/README.ko.md
CHANGED
|
@@ -149,7 +149,7 @@ fluo의 Fastify 어댑터는 높은 동시성 시나리오에서 raw Node.js 어
|
|
|
149
149
|
|
|
150
150
|
## 공개 API 개요
|
|
151
151
|
|
|
152
|
-
- `createFastifyAdapter(options)`: Fastify 어댑터를 위한 권장 팩토리입니다.
|
|
152
|
+
- `createFastifyAdapter(options, multipartOptions?)`: Fastify 어댑터를 위한 권장 팩토리입니다. 선택적 두 번째 인자는 직접 어댑터를 생성할 때 `maxFileSize`, `maxFiles`, `maxTotalSize` 같은 multipart 제한을 설정합니다.
|
|
153
153
|
- `bootstrapFastifyApplication(module, options)`: 암시적 리스닝 없이 수행하는 고급 부트스트랩입니다.
|
|
154
154
|
- `runFastifyApplication(module, options)`: 생명주기 관리를 포함한 빠른 시작 헬퍼입니다. timeout/실패 시에는 해당 상태를 로그와 `process.exitCode`로 보고하고, 최종 프로세스 종료는 주변 호스트에 맡깁니다.
|
|
155
155
|
- `isFastifyMultipartTooLargeError(error)`: Fastify error shape 전반에서 multipart limit error를 감지합니다.
|
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ The same file also covers Fastify-specific native route registration with wildca
|
|
|
149
149
|
|
|
150
150
|
## Public API Overview
|
|
151
151
|
|
|
152
|
-
- `createFastifyAdapter(options)`: Recommended factory for the Fastify adapter.
|
|
152
|
+
- `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.
|
|
153
153
|
- `bootstrapFastifyApplication(module, options)`: advanced bootstrap without implicit listening.
|
|
154
154
|
- `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.
|
|
155
155
|
- `isFastifyMultipartTooLargeError(error)`: Detects multipart limit errors across Fastify error shapes.
|
package/dist/adapter.js
CHANGED
|
@@ -2,10 +2,10 @@ import { Transform } from 'node:stream';
|
|
|
2
2
|
import multipart from '@fastify/multipart';
|
|
3
3
|
import { createErrorResponse, createServerBackedHttpAdapterRealtimeCapability, HttpException, InternalServerErrorException, PayloadTooLargeException } from '@fluojs/http';
|
|
4
4
|
import { attachFrameworkRequestNativeRouteHandoff, bindRawRequestNativeRouteHandoff, consumeRawRequestNativeRouteHandoff, isRoutePathNormalizationSensitive } from '@fluojs/http/internal';
|
|
5
|
-
import { bootstrapHttpAdapterApplication,
|
|
5
|
+
import { bootstrapHttpAdapterApplication, runHttpAdapterApplication } from '@fluojs/runtime/internal/http-adapter';
|
|
6
6
|
import { dispatchWithRequestResponseFactory } from '@fluojs/runtime/internal/request-response-factory';
|
|
7
7
|
import { cloneHeaderValue, createDeferredFrameworkRequestShell, createMemoizedAsyncValue, createMemoizedValue, parseQueryParamsFromSearch, snapshotSimpleQueryRecord, splitRawRequestUrl } from '@fluojs/runtime/internal-node';
|
|
8
|
-
import { createNodeShutdownSignalRegistration, defaultNodeShutdownSignals } from '@fluojs/runtime/node';
|
|
8
|
+
import { createConsoleApplicationLogger, createNodeShutdownSignalRegistration, defaultNodeShutdownSignals } from '@fluojs/runtime/node';
|
|
9
9
|
import fastify from 'fastify';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -217,7 +217,7 @@ function createNativeFastFrameworkRequest(request, lazySignal, urlParts, maxBody
|
|
|
217
217
|
query: readSimpleQueryRecord(request.query),
|
|
218
218
|
queryFactory: () => parseQueryParamsFromSearch(urlParts.search),
|
|
219
219
|
raw: request.raw,
|
|
220
|
-
requestId:
|
|
220
|
+
requestId: resolveRequestIdFromHeaders(request.raw.headers),
|
|
221
221
|
signal: lazySignal.signal,
|
|
222
222
|
url: urlParts.path + urlParts.search
|
|
223
223
|
});
|
|
@@ -563,7 +563,7 @@ function createDeferredFrameworkRequest(request, signal, multipartOptions, maxBo
|
|
|
563
563
|
query: querySnapshot,
|
|
564
564
|
queryFactory: () => parseQueryParamsFromSearch(urlParts.search),
|
|
565
565
|
raw: request.raw,
|
|
566
|
-
requestId:
|
|
566
|
+
requestId: resolveRequestIdFromHeaders(headerSnapshot),
|
|
567
567
|
signal,
|
|
568
568
|
url: urlParts.path + urlParts.search
|
|
569
569
|
});
|
|
@@ -746,10 +746,6 @@ function resolveRequestIdFromHeaders(headers) {
|
|
|
746
746
|
const requestId = headers['x-request-id'] ?? headers['x-correlation-id'];
|
|
747
747
|
return Array.isArray(requestId) ? requestId[0] : requestId;
|
|
748
748
|
}
|
|
749
|
-
function resolvePrimaryRequestIdFromHeaders(headers) {
|
|
750
|
-
const requestId = headers['x-request-id'];
|
|
751
|
-
return Array.isArray(requestId) ? requestId[0] : requestId;
|
|
752
|
-
}
|
|
753
749
|
function createFastifyApp(httpsOptions, maxBodySize) {
|
|
754
750
|
if (httpsOptions) {
|
|
755
751
|
return fastify({
|
|
@@ -780,8 +776,14 @@ function captureRawBodyPreParsingHook(request, _reply, payload, done) {
|
|
|
780
776
|
}
|
|
781
777
|
const chunks = [];
|
|
782
778
|
const capture = new Transform({
|
|
783
|
-
transform(chunk,
|
|
784
|
-
|
|
779
|
+
transform(chunk, encoding, callback) {
|
|
780
|
+
let bufferChunk;
|
|
781
|
+
try {
|
|
782
|
+
bufferChunk = createRawBodyBufferChunk(chunk, encoding);
|
|
783
|
+
} catch (error) {
|
|
784
|
+
callback(error instanceof Error ? error : new Error(String(error)));
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
785
787
|
chunks.push(bufferChunk);
|
|
786
788
|
capture.receivedEncodedLength += bufferChunk.byteLength;
|
|
787
789
|
callback(null, chunk);
|
|
@@ -800,6 +802,18 @@ function captureRawBodyPreParsingHook(request, _reply, payload, done) {
|
|
|
800
802
|
payload.pipe(capture);
|
|
801
803
|
done(null, capture);
|
|
802
804
|
}
|
|
805
|
+
function createRawBodyBufferChunk(chunk, encoding) {
|
|
806
|
+
if (Buffer.isBuffer(chunk)) {
|
|
807
|
+
return chunk;
|
|
808
|
+
}
|
|
809
|
+
if (chunk instanceof Uint8Array) {
|
|
810
|
+
return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
811
|
+
}
|
|
812
|
+
if (typeof chunk === 'string') {
|
|
813
|
+
return Buffer.from(chunk, encoding);
|
|
814
|
+
}
|
|
815
|
+
throw new TypeError(`Fastify raw-body capture received unsupported ${typeof chunk} stream chunk.`);
|
|
816
|
+
}
|
|
803
817
|
function isMultipartRequestContentType(contentType) {
|
|
804
818
|
const primaryValue = Array.isArray(contentType) ? contentType[0] : contentType;
|
|
805
819
|
return typeof primaryValue === 'string' && primaryValue.toLowerCase().includes('multipart/form-data');
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"platform",
|
|
9
9
|
"server"
|
|
10
10
|
],
|
|
11
|
-
"version": "1.0.
|
|
11
|
+
"version": "1.0.8",
|
|
12
12
|
"private": false,
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"@fastify/multipart": "^9.2.1",
|
|
39
39
|
"fastify": "^5.8.5",
|
|
40
40
|
"fastify-raw-body": "^5.0.0",
|
|
41
|
-
"@fluojs/http": "^1.1.
|
|
42
|
-
"@fluojs/runtime": "^1.1.
|
|
41
|
+
"@fluojs/http": "^1.1.2",
|
|
42
|
+
"@fluojs/runtime": "^1.1.8"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"vitest": "^3.2.4",
|
|
46
46
|
"@fluojs/di": "^1.1.0",
|
|
47
|
-
"@fluojs/testing": "^1.0.
|
|
47
|
+
"@fluojs/testing": "^1.0.6"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"prebuild": "node ../../tooling/scripts/clean-dist.mjs",
|