@fluojs/serialization 1.0.0-beta.1 → 1.0.0-beta.2
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
CHANGED
|
@@ -129,6 +129,8 @@ class UsersController {
|
|
|
129
129
|
}
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
`SerializerInterceptor`는 일반 HTTP 응답 writer가 아직 소유한 값만 직렬화합니다. 핸들러나 응답 헬퍼가 SSE 스트림처럼 `RequestContext.response`를 직접 커밋한 경우, 인터셉터는 해당 핸들러 소유 값을 그대로 반환하여 request pipeline의 응답 소유권을 보존합니다.
|
|
133
|
+
|
|
132
134
|
## 공개 API 개요
|
|
133
135
|
|
|
134
136
|
### 데코레이터
|
package/README.md
CHANGED
|
@@ -97,6 +97,8 @@ class UsersController {
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
`SerializerInterceptor` only serializes values that still belong to the normal HTTP response writer. If a handler or response helper commits `RequestContext.response` directly, such as an SSE stream, the interceptor returns that handler-owned value unchanged so the request pipeline preserves response ownership.
|
|
101
|
+
|
|
100
102
|
### Cycle-safe serialization
|
|
101
103
|
|
|
102
104
|
The serializer cuts cyclic references safely instead of recursing forever, so complex object graphs can still be turned into plain response-shaped objects without unbounded recursion.
|
|
@@ -8,6 +8,6 @@ import type { CallHandler, Interceptor, InterceptorContext } from '@fluojs/http'
|
|
|
8
8
|
* automatically.
|
|
9
9
|
*/
|
|
10
10
|
export declare class SerializerInterceptor implements Interceptor {
|
|
11
|
-
intercept(
|
|
11
|
+
intercept(context: InterceptorContext, next: CallHandler): Promise<unknown>;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=serializer-interceptor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer-interceptor.d.ts","sourceRoot":"","sources":["../src/serializer-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIjF;;;;;;;GAOG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IACjD,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"serializer-interceptor.d.ts","sourceRoot":"","sources":["../src/serializer-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIjF;;;;;;;GAOG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IACjD,SAAS,CAAC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CASlF"}
|
|
@@ -9,8 +9,11 @@ import { serialize } from './serialize.js';
|
|
|
9
9
|
* automatically.
|
|
10
10
|
*/
|
|
11
11
|
export class SerializerInterceptor {
|
|
12
|
-
async intercept(
|
|
12
|
+
async intercept(context, next) {
|
|
13
13
|
const value = await next.handle();
|
|
14
|
+
if (context.requestContext.response.committed) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
14
17
|
return serialize(value);
|
|
15
18
|
}
|
|
16
19
|
}
|