Initial boiler plate project

This commit is contained in:
2024-09-24 03:52:46 +00:00
parent 6120b2d6c3
commit 154b93e267
10034 changed files with 2079352 additions and 2 deletions

View File

@ -0,0 +1,28 @@
import { ACTION } from "../../client/components/app-router-headers";
export function getServerActionRequestMetadata(req) {
let actionId;
let contentType;
if (req.headers instanceof Headers) {
actionId = req.headers.get(ACTION.toLowerCase()) ?? null;
contentType = req.headers.get("content-type");
} else {
actionId = req.headers[ACTION.toLowerCase()] ?? null;
contentType = req.headers["content-type"] ?? null;
}
const isURLEncodedAction = Boolean(req.method === "POST" && contentType === "application/x-www-form-urlencoded");
const isMultipartAction = Boolean(req.method === "POST" && (contentType == null ? void 0 : contentType.startsWith("multipart/form-data")));
const isFetchAction = Boolean(actionId !== undefined && typeof actionId === "string" && req.method === "POST");
const isServerAction = Boolean(isFetchAction || isURLEncodedAction || isMultipartAction);
return {
actionId,
isURLEncodedAction,
isMultipartAction,
isFetchAction,
isServerAction
};
}
export function getIsServerAction(req) {
return getServerActionRequestMetadata(req).isServerAction;
}
//# sourceMappingURL=server-action-request-meta.js.map