Estrae la deduplica degli id giocatore in idsConNotificheAttive (src/lib/notifiche-attive.server.ts), testata a livello unit. Aggiunge un test di integrazione sui permessi della route (401/403/200), sullo stesso schema di permessi-route.test.ts. Documenta il nuovo endpoint in notifiche.md e la dashboard admin a tab in profilo-giocatore.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
26 lines
883 B
TypeScript
26 lines
883 B
TypeScript
import { createFileRoute } from "@tanstack/react-router";
|
|
import { richiediAdmin } from "@/lib/auth-route.server";
|
|
import { idsConNotificheAttive } from "@/lib/notifiche-attive.server";
|
|
|
|
export const Route = createFileRoute("/api/public/notifiche-attive")({
|
|
server: {
|
|
handlers: {
|
|
GET: async ({ request }) => {
|
|
const negato = await richiediAdmin(request);
|
|
if (negato) return negato;
|
|
|
|
const { supabaseAdmin } = await import("@/integrations/supabase/client.server");
|
|
const { data, error } = await supabaseAdmin
|
|
.from("push_subscriptions")
|
|
.select("giocatore_id");
|
|
if (error) {
|
|
console.error("notifiche-attive", error);
|
|
return new Response("Errore lettura", { status: 500 });
|
|
}
|
|
|
|
return Response.json({ giocatoreIds: idsConNotificheAttive(data ?? []) });
|
|
},
|
|
},
|
|
},
|
|
});
|