furality-stream-recorder/src/setlist.ts
Lillith Rose (Device: Lucia) fdeba8fd41
Some checks are pending
Build Docker Image / docker (push) Waiting to run
Test / test (push) Waiting to run
Initial Commit
2025-06-08 14:33:19 -04:00

43 lines
954 B
TypeScript

export interface Event {
id: string;
name: string;
start: string;
end: string;
description?: string;
subtitle?: string;
type: string;
imageUrl: string;
questCompatible: boolean;
pcCompatible: boolean;
livestream: boolean;
status: string;
supporter: boolean;
rsvp: boolean;
vote: any;
}
export let events: Event[] | null = null;
export async function loadEvents() {
console.log("Loading Events");
const { data }: { data: Event[] } = await fetch(
"https://api.fynn.ai/v2/event"
).then((i) => i.json());
events = data.filter((i) => i.type === "dj");
console.log(`Loaded ${events.length} DJ events`);
return events;
}
export function getCurrentEvent(): Event | null {
if (!events) return null;
const now = new Date();
return (
events.find((event) => {
const start = new Date(event.start);
const end = new Date(event.end);
return now >= start && now <= end;
}) || null
);
}