getRequestData() — astro Function Reference
Architecture documentation for the getRequestData() function in endpoint.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD c5f573bc_c331_b3bf_df53_a41f0f3f2f93["getRequestData()"] 97c01b61_891f_8dac_ac27_a13227b30c79["endpoint.ts"] c5f573bc_c331_b3bf_df53_a41f0f3f2f93 -->|defined in| 97c01b61_891f_8dac_ac27_a13227b30c79 68ec4090_d8c0_118b_1279_46cbcbc1885f["createEndpoint()"] 68ec4090_d8c0_118b_1279_46cbcbc1885f -->|calls| c5f573bc_c331_b3bf_df53_a41f0f3f2f93 49468a1d_0527_5782_dbba_2c2905ab91b9["badRequest()"] c5f573bc_c331_b3bf_df53_a41f0f3f2f93 -->|calls| 49468a1d_0527_5782_dbba_2c2905ab91b9 style c5f573bc_c331_b3bf_df53_a41f0f3f2f93 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/server-islands/endpoint.ts lines 58–105
async function getRequestData(request: Request): Promise<Response | RenderOptions> {
switch (request.method) {
case 'GET': {
const url = new URL(request.url);
const params = url.searchParams;
if (!params.has('s') || !params.has('e') || !params.has('p')) {
return badRequest('Missing required query parameters.');
}
const encryptedSlots = params.get('s')!;
return {
encryptedComponentExport: params.get('e')!,
encryptedProps: params.get('p')!,
encryptedSlots,
};
}
case 'POST': {
try {
const raw = await request.text();
const data = JSON.parse(raw);
// Validate that slots is not plaintext
if ('slots' in data && typeof data.slots === 'object') {
return badRequest('Plaintext slots are not allowed. Slots must be encrypted.');
}
// Validate that componentExport is not plaintext
if ('componentExport' in data && typeof data.componentExport === 'string') {
return badRequest(
'Plaintext componentExport is not allowed. componentExport must be encrypted.',
);
}
return data as RenderOptions;
} catch (e) {
if (e instanceof SyntaxError) {
return badRequest('Request format is invalid.');
}
throw e;
}
}
default: {
// Method not allowed: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
return new Response(null, { status: 405 });
}
}
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does getRequestData() do?
getRequestData() is a function in the astro codebase, defined in packages/astro/src/core/server-islands/endpoint.ts.
Where is getRequestData() defined?
getRequestData() is defined in packages/astro/src/core/server-islands/endpoint.ts at line 58.
What does getRequestData() call?
getRequestData() calls 1 function(s): badRequest.
What calls getRequestData()?
getRequestData() is called by 1 function(s): createEndpoint.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free