Home / Function/ getFormServerHandler() — astro Function Reference

getFormServerHandler() — astro Function Reference

Architecture documentation for the getFormServerHandler() function in server.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  a0bc39ba_2938_607e_8820_271766974a1b["getFormServerHandler()"]
  12df90c3_b0fe_d858_b821_5011b6067fdb["server.ts"]
  a0bc39ba_2938_607e_8820_271766974a1b -->|defined in| 12df90c3_b0fe_d858_b821_5011b6067fdb
  246d72b2_472d_5097_3c81_0588c08ec2c9["defineAction()"]
  246d72b2_472d_5097_3c81_0588c08ec2c9 -->|calls| a0bc39ba_2938_607e_8820_271766974a1b
  258b6bef_aced_8d2a_aea4_de1c127c32ab["parseFormInput()"]
  a0bc39ba_2938_607e_8820_271766974a1b -->|calls| 258b6bef_aced_8d2a_aea4_de1c127c32ab
  style a0bc39ba_2938_607e_8820_271766974a1b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/actions/runtime/server.ts lines 73–94

function getFormServerHandler<TOutput, TInputSchema extends z.$ZodType>(
	handler: ActionHandler<TInputSchema, TOutput>,
	inputSchema?: TInputSchema,
) {
	return async (unparsedInput: unknown, context: ActionAPIContext): Promise<Awaited<TOutput>> => {
		if (!(unparsedInput instanceof FormData)) {
			throw new ActionError({
				code: 'UNSUPPORTED_MEDIA_TYPE',
				message: 'This action only accepts FormData.',
			});
		}

		if (!inputSchema) return await handler(unparsedInput, context);

		const parsed = await parseFormInput(inputSchema, unparsedInput);

		if (!parsed.success) {
			throw new ActionInputError(parsed.error.issues);
		}
		return await handler(parsed.data, context);
	};
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getFormServerHandler() do?
getFormServerHandler() is a function in the astro codebase, defined in packages/astro/src/actions/runtime/server.ts.
Where is getFormServerHandler() defined?
getFormServerHandler() is defined in packages/astro/src/actions/runtime/server.ts at line 73.
What does getFormServerHandler() call?
getFormServerHandler() calls 1 function(s): parseFormInput.
What calls getFormServerHandler()?
getFormServerHandler() is called by 1 function(s): defineAction.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free