@wocart/storefront v3.1.0
@wocart/storefront / astro / createProxyEndpoint
createProxyEndpoint<TInput, TOutput>(config): AstroAPIRoute
Create a proxy endpoint handler
Type Parameters
TInput
TInput
TOutput
TOutput
Parameters
config
ProxyEndpointConfig<TInput, TOutput>
Returns
AstroAPIRoute
Example
// POST endpoint with validation
export const POST = createProxyEndpoint({
method: 'POST',
client: validateCart,
inputSchema: cartSchema,
csrfProtection: true,
});
// GET endpoint with path params
export const GET = createProxyEndpoint({
method: 'GET',
client: fetchCommunes,
pathParams: { wilayaId: 'number' },
});