@fluojs/platform-bun 1.0.4 → 1.0.6
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 +2 -2
- package/README.md +2 -2
- package/dist/adapter.d.ts +1 -3
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +36 -19
- package/package.json +3 -3
package/README.ko.md
CHANGED
|
@@ -100,11 +100,11 @@ Native handoff가 붙은 뒤 app middleware가 framework request의 method 또
|
|
|
100
100
|
- **런타임 host**: 이 패키지는 listen 시점에 `globalThis.Bun.serve()`가 필요합니다. 테스트에서는 Bun 호환 test double을 제공할 수 있지만, production 사용은 Bun 전용입니다.
|
|
101
101
|
- **요청 portability**: Fetch 요청은 shared web dispatcher를 통해 변환되며 malformed cookie 값, query 배열, `rawBody: true`일 때 JSON/text raw body, custom `createBunFetchHandler(...)` 설정의 byte-exact request handoff, SSE framing을 보존합니다.
|
|
102
102
|
- **네이티브 route 가속**: Bun의 `routes` object를 사용할 수 있고 fluo route shape를 의미 보존 상태로 선등록할 수 있을 때만 Bun이 path matching을 먼저 처리하고, 이후 요청은 다시 shared dispatcher로 넘깁니다. 지원하지 않거나 모호한 route shape는 일반 `fetch` 경로로 폴백하며, middleware가 handler matching 전에 method/path를 rewrite하면 stale handoff는 무시됩니다.
|
|
103
|
-
- **네이티브 route gate**: Native route는 Bun `>=1.2.3`에서만 활성화됩니다. Versioned route, `ALL` handler, same-shape conflict, normalization-sensitive path, `OPTIONS`/CORS preflight는 fetch/shared-dispatch path에 남습니다.
|
|
103
|
+
- **네이티브 route gate**: Native route는 Bun `>=1.2.3`에서만 활성화됩니다. Adapter는 안전한 native-route entry가 실제로 활성화될 때만 `routes` 옵션을 전달하고, 그 외에는 `routes` 옵션 자체를 생략합니다. Versioned route, `ALL` handler, same-shape conflict, normalization-sensitive path, `OPTIONS`/CORS preflight는 fetch/shared-dispatch path에 남습니다.
|
|
104
104
|
- **Multipart 동작**: Multipart 요청은 `rawBody`를 노출하지 않으며 multipart limit은 shared runtime parser를 통해 계속 적용됩니다.
|
|
105
105
|
- **시작 target**: `hostname`, `port`, `tls`는 `Bun.serve()`로 전달됩니다. 시작 로그는 설정된 HTTP 또는 HTTPS listen URL을 보고합니다.
|
|
106
106
|
- **종료 소유권**: `close()`는 새 HTTP 및 websocket-upgrade 유입을 `503` shutdown 응답으로 중단하고, in-flight HTTP handler를 기다린 뒤, drain이 끝나면 adapter state를 정리하며 `runBunApplication()`이 등록한 signal listener를 제거합니다.
|
|
107
|
-
- **Realtime seam**: Bun websocket binding은 서버를 시작하는 `listen()` 전에 구성해야 합니다. Adapter가 새 유입을 받는 동안 Upgrade 요청은 HTTP dispatch로 넘어가기 전에 구성된 binding에 먼저
|
|
107
|
+
- **Realtime seam**: Bun websocket binding은 서버를 시작하는 `listen()` 전에 구성해야 합니다. Adapter가 새 유입을 받는 동안 Upgrade 요청은 HTTP dispatch로 넘어가기 전에 구성된 binding에 먼저 전달되며, binding이 response를 반환하거나 요청 업그레이드에 성공한 경우에만 HTTP fallback을 억제합니다.
|
|
108
108
|
- **Adapter instance helper**: `BunHttpApplicationAdapter`는 `getServer()`, `getListenTarget()`, `getRealtimeCapability()`, `configureRealtimeBinding()`, `configureWebSocketBinding()`, `listen()`, `close()`를 노출합니다.
|
|
109
109
|
|
|
110
110
|
## Conformance 커버리지
|
package/README.md
CHANGED
|
@@ -100,11 +100,11 @@ The adapter also exports the typed Bun integration seams used by realtime packag
|
|
|
100
100
|
- **Runtime host**: This package requires `globalThis.Bun.serve()` at listen time. Tests may provide a Bun-compatible test double, but production use is Bun-only.
|
|
101
101
|
- **Request portability**: Fetch requests are translated through the shared web dispatcher, preserving malformed cookie values, query arrays, JSON/text raw bodies when `rawBody: true`, byte-exact request handoff for custom `createBunFetchHandler(...)` setups, and SSE framing.
|
|
102
102
|
- **Native route acceleration**: When Bun's `routes` object is available and a fluo route shape is semantically safe to pre-register, the adapter lets Bun short-circuit path matching before handing the request back to the shared dispatcher. Unsupported or ambiguous route shapes fall back to the regular `fetch` path, and stale handoffs are ignored if middleware rewrites method/path before handler matching.
|
|
103
|
-
- **Native route gate**: Native routes are enabled only on Bun `>=1.2.3`;
|
|
103
|
+
- **Native route gate**: Native routes are enabled only on Bun `>=1.2.3`; the adapter omits the `routes` option entirely unless safe native-route entries are concretely enabled. Versioned routes, `ALL` handlers, same-shape conflicts, normalization-sensitive paths, and `OPTIONS`/CORS preflight stay on the fetch/shared-dispatch path.
|
|
104
104
|
- **Multipart behavior**: Multipart requests never expose `rawBody`, and multipart limits continue to flow through the shared runtime parser.
|
|
105
105
|
- **Startup target**: `hostname`, `port`, and `tls` are forwarded to `Bun.serve()`. Startup logs report the configured HTTP or HTTPS listen URL.
|
|
106
106
|
- **Shutdown ownership**: `close()` stops new HTTP and websocket-upgrade ingress with a `503` shutdown response, waits for in-flight HTTP handlers, clears adapter state after drain settles, and removes signal listeners registered by `runBunApplication()`.
|
|
107
|
-
- **Realtime seam**: Bun websocket bindings must be configured before `listen()` starts the server. Upgrade requests are offered to the configured binding before falling back to HTTP dispatch while the adapter is accepting new ingress.
|
|
107
|
+
- **Realtime seam**: Bun websocket bindings must be configured before `listen()` starts the server. Upgrade requests are offered to the configured binding before falling back to HTTP dispatch while the adapter is accepting new ingress; HTTP fallback is suppressed only after the binding returns a response or successfully upgrades the request.
|
|
108
108
|
- **Adapter instance helpers**: `BunHttpApplicationAdapter` exposes `getServer()`, `getListenTarget()`, `getRealtimeCapability()`, `configureRealtimeBinding()`, `configureWebSocketBinding()`, `listen()`, and `close()`.
|
|
109
109
|
|
|
110
110
|
## Conformance Coverage
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CorsOptions, Dispatcher, HttpApplicationAdapter, HttpMethod, MiddlewareLike, SecurityHeadersOptions } from '@fluojs/http';
|
|
2
|
-
import type { Application,
|
|
2
|
+
import type { Application, CreateApplicationOptions, ModuleType, MultipartOptions, UploadedFile } from '@fluojs/runtime';
|
|
3
3
|
import { type HttpAdapterListenTarget } from '@fluojs/runtime/internal/http-adapter';
|
|
4
4
|
declare module '@fluojs/http' {
|
|
5
5
|
interface FrameworkRequest {
|
|
@@ -144,8 +144,6 @@ export interface BootstrapBunApplicationOptions extends Omit<CreateApplicationOp
|
|
|
144
144
|
hostname?: BunHostname;
|
|
145
145
|
/** Idle timeout passed through to `Bun.serve()`. */
|
|
146
146
|
idleTimeout?: number;
|
|
147
|
-
/** Application logger used for startup, shutdown, and failure reporting. */
|
|
148
|
-
logger?: ApplicationLogger;
|
|
149
147
|
/** Maximum request body size forwarded as Bun's `maxRequestBodySize`. */
|
|
150
148
|
maxBodySize?: number;
|
|
151
149
|
/** Middleware applied by the shared HTTP bootstrap path. */
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EAEV,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,sBAAsB,EACvB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EACV,WAAW,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EAEV,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,sBAAsB,EACvB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EACV,WAAW,EAEX,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,KAAK,uBAAuB,EAG7B,MAAM,uCAAuC,CAAC;AAG/C,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,gBAAgB;QACxB,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;QACvB,OAAO,CAAC,EAAE,UAAU,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AAK,EAAE,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,GAAG,SAAS,GAAG,IAAI;IAQtF,iFAAiF;IACjF,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,GAAG,SAAS,GAAG,IAAI;IAIvF,mFAAmF;IAC7E,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA2CnD,oFAAoF;IAC9E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAgCd,mBAAmB;IAmBjC,OAAO,CAAC,oBAAoB;YAqBd,uBAAuB;CAOtC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,yBAAgE,EAChE,WAAW,EACX,SAAS,EACT,OAAO,GACR,EAAE,4BAA4B,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAmBxE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,sBAAsB,CAExF;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC,CAkBtB"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bindRawRequestNativeRouteHandoff, createFetchStyleHttpAdapterRealtimeCapability, isRoutePathNormalizationSensitive } from '@fluojs/http/internal';
|
|
2
|
+
import { bootstrapHttpAdapterApplication, createDefaultApplicationLogger, runHttpAdapterApplication } from '@fluojs/runtime/internal/http-adapter';
|
|
2
3
|
import { createWebRequestResponseFactory, dispatchWebRequest } from '@fluojs/runtime/web';
|
|
3
|
-
import { bootstrapHttpAdapterApplication, createConsoleApplicationLogger, runHttpAdapterApplication } from '@fluojs/runtime/internal/http-adapter';
|
|
4
4
|
|
|
5
5
|
/** Shutdown signal names that `runBunApplication()` can register. */
|
|
6
6
|
|
|
@@ -118,24 +118,28 @@ export class BunHttpApplicationAdapter {
|
|
|
118
118
|
return createShutdownResponse();
|
|
119
119
|
}
|
|
120
120
|
if (realtimeBinding) {
|
|
121
|
-
const
|
|
122
|
-
if (handled !== undefined ||
|
|
123
|
-
return handled;
|
|
121
|
+
const realtimeResult = await dispatchRealtimeBindingRequest(realtimeBinding, request, server);
|
|
122
|
+
if (realtimeResult.handled !== undefined || realtimeResult.upgraded) {
|
|
123
|
+
return realtimeResult.handled;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
return await this.dispatchHttpRequest(request);
|
|
127
127
|
};
|
|
128
|
-
|
|
128
|
+
const nativeRoutes = createBunNativeRoutes(dispatcher, handleRequest, bun);
|
|
129
|
+
const serveOptions = {
|
|
129
130
|
development: this.options.development,
|
|
130
131
|
fetch: handleRequest,
|
|
131
132
|
hostname: this.options.hostname,
|
|
132
133
|
idleTimeout: realtimeBinding?.idleTimeout ?? this.options.idleTimeout,
|
|
133
134
|
maxRequestBodySize: realtimeBinding?.maxRequestBodySize ?? this.options.maxBodySize,
|
|
134
135
|
port: resolvePort(this.options.port),
|
|
135
|
-
routes: createBunNativeRoutes(dispatcher, handleRequest, bun),
|
|
136
136
|
tls: this.options.tls,
|
|
137
137
|
websocket: realtimeBinding?.websocket
|
|
138
|
-
}
|
|
138
|
+
};
|
|
139
|
+
this.server = bun.serve(nativeRoutes ? {
|
|
140
|
+
...serveOptions,
|
|
141
|
+
routes: nativeRoutes
|
|
142
|
+
} : serveOptions);
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
/** Stops ingress, waits for in-flight HTTP handlers, and releases adapter state. */
|
|
@@ -250,11 +254,8 @@ export function createBunAdapter(options = {}) {
|
|
|
250
254
|
* @returns The bootstrapped application; call `listen()` to start serving.
|
|
251
255
|
*/
|
|
252
256
|
export async function bootstrapBunApplication(rootModule, options) {
|
|
253
|
-
const logger =
|
|
254
|
-
return bootstrapHttpAdapterApplication(rootModule, {
|
|
255
|
-
...options,
|
|
256
|
-
logger
|
|
257
|
-
}, createBunAdapter({
|
|
257
|
+
const logger = createDefaultApplicationLogger();
|
|
258
|
+
return bootstrapHttpAdapterApplication(rootModule, options, createBunAdapter({
|
|
258
259
|
development: options.development,
|
|
259
260
|
hostname: options.hostname,
|
|
260
261
|
idleTimeout: options.idleTimeout,
|
|
@@ -264,7 +265,7 @@ export async function bootstrapBunApplication(rootModule, options) {
|
|
|
264
265
|
rawBody: options.rawBody,
|
|
265
266
|
stopActiveConnections: options.stopActiveConnections,
|
|
266
267
|
tls: options.tls
|
|
267
|
-
}));
|
|
268
|
+
}), logger);
|
|
268
269
|
}
|
|
269
270
|
|
|
270
271
|
/**
|
|
@@ -275,7 +276,7 @@ export async function bootstrapBunApplication(rootModule, options) {
|
|
|
275
276
|
* @returns The running application instance.
|
|
276
277
|
*/
|
|
277
278
|
export async function runBunApplication(rootModule, options) {
|
|
278
|
-
const logger =
|
|
279
|
+
const logger = createDefaultApplicationLogger();
|
|
279
280
|
const adapter = createBunAdapter({
|
|
280
281
|
development: options.development,
|
|
281
282
|
hostname: options.hostname,
|
|
@@ -289,9 +290,8 @@ export async function runBunApplication(rootModule, options) {
|
|
|
289
290
|
});
|
|
290
291
|
return runHttpAdapterApplication(rootModule, {
|
|
291
292
|
...options,
|
|
292
|
-
logger,
|
|
293
293
|
shutdownRegistration: createBunShutdownSignalRegistration(options.shutdownSignals ?? defaultBunShutdownSignals())
|
|
294
|
-
}, adapter);
|
|
294
|
+
}, adapter, logger);
|
|
295
295
|
}
|
|
296
296
|
function defaultBunShutdownSignals() {
|
|
297
297
|
return ['SIGINT', 'SIGTERM'];
|
|
@@ -370,6 +370,26 @@ function validateNonNegativeIntegerOption(name, value) {
|
|
|
370
370
|
throw new Error(`Invalid ${name} value: ${String(value)}. Expected a non-negative integer.`);
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
+
async function dispatchRealtimeBindingRequest(binding, request, server) {
|
|
374
|
+
let upgraded = false;
|
|
375
|
+
const trackedServer = {
|
|
376
|
+
fetch: server.fetch ? trackedRequest => server.fetch?.(trackedRequest) : undefined,
|
|
377
|
+
hostname: server.hostname,
|
|
378
|
+
port: server.port,
|
|
379
|
+
stop: closeActiveConnections => server.stop(closeActiveConnections),
|
|
380
|
+
upgrade(upgradeRequest, options) {
|
|
381
|
+
const didUpgrade = server.upgrade(upgradeRequest, options);
|
|
382
|
+
upgraded ||= didUpgrade;
|
|
383
|
+
return didUpgrade;
|
|
384
|
+
},
|
|
385
|
+
url: server.url
|
|
386
|
+
};
|
|
387
|
+
const handled = await binding.fetch(request, trackedServer);
|
|
388
|
+
return {
|
|
389
|
+
handled,
|
|
390
|
+
upgraded
|
|
391
|
+
};
|
|
392
|
+
}
|
|
373
393
|
function createBunNativeRoutes(dispatcher, handleRequest, bun) {
|
|
374
394
|
if (!supportsBunNativeRoutes(bun)) {
|
|
375
395
|
return undefined;
|
|
@@ -545,7 +565,4 @@ function waitForCloseWithTimeout(closePromise, timeoutMs) {
|
|
|
545
565
|
});
|
|
546
566
|
});
|
|
547
567
|
}
|
|
548
|
-
function isWebSocketUpgradeRequest(request) {
|
|
549
|
-
return request.headers.get('upgrade')?.toLowerCase() === 'websocket';
|
|
550
|
-
}
|
|
551
568
|
const bunRouteMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'];
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"platform",
|
|
9
9
|
"server"
|
|
10
10
|
],
|
|
11
|
-
"version": "1.0.
|
|
11
|
+
"version": "1.0.6",
|
|
12
12
|
"private": false,
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@fluojs/http": "^1.1.
|
|
36
|
-
"@fluojs/runtime": "^1.1.
|
|
35
|
+
"@fluojs/http": "^1.1.1",
|
|
36
|
+
"@fluojs/runtime": "^1.1.7"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"vitest": "^3.2.4"
|