@faapi/faapi 6.10.1 → 6.11.0
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/cli/index.js +14 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/testing.js +10 -2
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/testing.js
CHANGED
|
@@ -1036,6 +1036,9 @@ async function injectParamsAsync(handler, ctx, body, injectors) {
|
|
|
1036
1036
|
function wrapResult(result, ctx) {
|
|
1037
1037
|
return wrapOkResult(result, ctx.config);
|
|
1038
1038
|
}
|
|
1039
|
+
function stashHandlerResult(ctx, result) {
|
|
1040
|
+
ctx.__faapiHandlerResult = result;
|
|
1041
|
+
}
|
|
1039
1042
|
function mergeMeta(response, meta) {
|
|
1040
1043
|
const hasMeta = meta.status !== void 0 || Object.keys(meta.headers).length > 0 || meta.setCookies.length > 0;
|
|
1041
1044
|
if (!hasMeta) return response;
|
|
@@ -1104,7 +1107,9 @@ async function invokeHandler(handler, ctx, body, middlewares, injectors) {
|
|
|
1104
1107
|
const result = await injectParamsAsync(handler, ctx, body, injectors);
|
|
1105
1108
|
const sseResponse = pickSseAndAutoClose();
|
|
1106
1109
|
if (sseResponse) return sseResponse;
|
|
1107
|
-
|
|
1110
|
+
const response = await toResponse(wrapResult(result, ctx), meta);
|
|
1111
|
+
if (!(result instanceof Response)) stashHandlerResult(ctx, result);
|
|
1112
|
+
return response;
|
|
1108
1113
|
} catch (err) {
|
|
1109
1114
|
autoCloseSseOnError();
|
|
1110
1115
|
throw err;
|
|
@@ -1115,7 +1120,9 @@ async function invokeHandler(handler, ctx, body, middlewares, injectors) {
|
|
|
1115
1120
|
const result = await injectParamsAsync(handler, ctx, body, injectors);
|
|
1116
1121
|
const sseResponse = pickSseAndAutoClose();
|
|
1117
1122
|
if (sseResponse) return sseResponse;
|
|
1118
|
-
|
|
1123
|
+
const response = await toResponse(wrapResult(result, ctx), meta);
|
|
1124
|
+
if (!(result instanceof Response)) stashHandlerResult(ctx, result);
|
|
1125
|
+
return response;
|
|
1119
1126
|
} catch (err) {
|
|
1120
1127
|
autoCloseSseOnError();
|
|
1121
1128
|
throw err;
|
|
@@ -4788,6 +4795,7 @@ async function handleRequest(routes, rootDir, dist, req, res, outerMiddlewares,
|
|
|
4788
4795
|
globalInjectors
|
|
4789
4796
|
});
|
|
4790
4797
|
const response = outerMiddlewares.length > 0 ? await compose(outerMiddlewares, ctx, routePipeline) : await routePipeline();
|
|
4798
|
+
res.__faapiHandlerResult = ctx.__faapiHandlerResult;
|
|
4791
4799
|
await sendSuccessResponse(response, res);
|
|
4792
4800
|
} catch (err) {
|
|
4793
4801
|
if (res.destroyed || res.writableEnded) return;
|