Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.

This commit is contained in:
becarta
2025-05-23 12:43:00 +02:00
parent f40db0f5c9
commit a544759a3b
11127 changed files with 1647032 additions and 0 deletions

45
node_modules/astro/dist/actions/runtime/route.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
import { ACTION_API_CONTEXT_SYMBOL, formContentTypes, hasContentType } from "./utils.js";
import { getAction } from "./virtual/get-action.js";
import { serializeActionResult } from "./virtual/shared.js";
const POST = async (context) => {
const { request, url } = context;
let baseAction;
try {
baseAction = await getAction(url.pathname);
} catch (e) {
if (import.meta.env.DEV) throw e;
console.error(e);
return new Response(e instanceof Error ? e.message : null, { status: 404 });
}
const contentType = request.headers.get("Content-Type");
const contentLength = request.headers.get("Content-Length");
let args;
if (!contentType || contentLength === "0") {
args = void 0;
} else if (contentType && hasContentType(contentType, formContentTypes)) {
args = await request.clone().formData();
} else if (contentType && hasContentType(contentType, ["application/json"])) {
args = await request.clone().json();
} else {
return new Response(null, { status: 415 });
}
const { getActionResult, callAction, props, redirect, ...actionAPIContext } = context;
Reflect.set(actionAPIContext, ACTION_API_CONTEXT_SYMBOL, true);
const action = baseAction.bind(actionAPIContext);
const result = await action(args);
const serialized = serializeActionResult(result);
if (serialized.type === "empty") {
return new Response(null, {
status: serialized.status
});
}
return new Response(serialized.body, {
status: serialized.status,
headers: {
"Content-Type": serialized.contentType
}
});
};
export {
POST
};