import * as faroe_user_server from "@faroe/user-server";
import * as astro from "astro";
const actions: faroe_user_server.Actions = {
// ...
};
const server = new faroe_user_server.Server(actions);
export async function (context: astro.APIContext): Promise<Response> {
// TODO: Protect route.
let bodyJSON: string;
try {
bodyJSON = await context.request.text();
} catch {
return new Response(null, { status: 400 });
}
let responseBodyJSON: string;
try {
responseBodyJSON = await server.resolveActionInvocationEndpointRequest(bodyJSON);
} catch {
return new Response(null, { status: 400 });
}
return new Response(responseBodyJSON, {
headers: {
"Content-Type": "application/json",
},
});
};