import root from "$lib/Utility/root"; export interface aniSearchBirthday { name: string; image: string; } const isAniSearchBirthday = (entry: unknown): entry is aniSearchBirthday => typeof entry === "object" && entry !== null && typeof (entry as { name?: unknown }).name === "string" && typeof (entry as { image?: unknown }).image === "string"; export const aniSearchBirthdays = async ( month: number, day: number, ): Promise => { const response = await fetch( root(`/api/birthdays/primary?month=${month}&day=${day}`), {}, ); if (!response.ok) throw new Error( `Primary birthdays request failed with ${response.status}.`, ); const data: unknown = await response.json(); if (!Array.isArray(data)) throw new Error("Primary birthdays response was not an array."); return data.filter(isAniSearchBirthday); };