@riddl/core 0.2.0 → 0.2.1
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/api.js +8 -1
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -63,11 +63,18 @@ export const api = async ({ routeModuleMap, config, base = "", cors = true, regi
|
|
|
63
63
|
if (!(endpoint === null || endpoint === void 0 ? void 0 : endpoint.handle)) {
|
|
64
64
|
throw error(405, "Method not allowed");
|
|
65
65
|
}
|
|
66
|
+
let ctxEvent = event;
|
|
67
|
+
for (const mw of routeWithMiddlewares.middlewares) {
|
|
68
|
+
ctxEvent = await mw.pre(ctxEvent);
|
|
69
|
+
}
|
|
66
70
|
const param = await parseParam(params !== null && params !== void 0 ? params : {}, endpoint);
|
|
67
71
|
const query = await parseQuery(request, endpoint);
|
|
68
72
|
const body = await parseBody(request, endpoint);
|
|
69
73
|
log("handler: %O", endpoint.handle);
|
|
70
|
-
const output = await endpoint.handle({ body, query, param, event });
|
|
74
|
+
const output = await endpoint.handle({ body, query, param, event: ctxEvent });
|
|
75
|
+
for (const mw of [...routeWithMiddlewares.middlewares].reverse()) {
|
|
76
|
+
ctxEvent = await mw.post(ctxEvent);
|
|
77
|
+
}
|
|
71
78
|
log("output: %O", output);
|
|
72
79
|
if (output instanceof Response) {
|
|
73
80
|
if (effectiveCorsSettings) {
|