Files
freno-dev/src/routes/auth/apple/notifications.ts
Michael Freno 5fc082178c cairn work
2026-01-21 01:56:54 -05:00

26 lines
924 B
TypeScript

import type { APIEvent } from "@solidjs/start/server";
import { verifyAppleNotification } from "~/server/apple-notification";
import { storeAppleNotificationUser } from "~/server/apple-notification-store";
export async function POST(event: APIEvent) {
const contentType = event.request.headers.get("content-type") || "";
if (!contentType.includes("application/json")) {
return new Response("Unsupported content type", { status: 415 });
}
try {
const payload = await event.request.json();
const notification = await verifyAppleNotification(payload);
await storeAppleNotificationUser(notification);
return new Response(JSON.stringify({ success: true }), {
status: 200,
headers: { "Content-Type": "application/json" }
});
} catch (error) {
console.error("Apple notification error:", error);
return new Response("Notification processing failed", { status: 400 });
}
}