Skip to content

Commit

Permalink
feat: add renderer error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Hebilicious committed Jun 12, 2023
1 parent c87aa42 commit 8786eae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/runtime/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ function createNitroApp(): NitroApp {
const regularHandlers = handlers.filter((h) => !h.formAction);

if (formActionsHandlers.length > 0) {
const renderer = handlers.find(({ route }) => route === "/**");
const renderer = regularHandlers.find(({ route }) => route === "/**");
if (!renderer) {
throw new Error(
"[Form Actions]: Missing renderer. Please properly set `nitro.options.renderer`."
);
}
const rendererHandler = lazyEventHandler(renderer.handler);

for (const h of formActionsHandlers) {
let handler = h.lazy ? lazyEventHandler(h.handler) : h.handler;
const routeRules = getRouteRulesForPath(h.route.replace(/:\w+|\*\*/g, "_"));
const routeRules = getRouteRulesForPath(
h.route.replace(/:\w+|\*\*/g, "_")
);
if (routeRules.cache) {
handler = cachedEventHandler(handler, {
group: "nitro/routes",
Expand Down

0 comments on commit 8786eae

Please sign in to comment.