Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/lib/api/esa-horaro/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import ky from "ky";

import type sampleSchedule from "./sample-schedule.json";

export const esaHoraro = async (eventSlug: string) => {
const result = await ky
.get(`https://horaro.org/-/api/v1/events/esa/schedules/${eventSlug}`)
.json<typeof sampleSchedule>();

const nameColumnIndex = result.data.columns.indexOf("Game");
const categoryColumnIndex = result.data.columns.indexOf("Category");
const platformColumnIndex = result.data.columns.indexOf("Platform");

return result.data.items.map((item) => {
const name = item.data[nameColumnIndex];
const category = item.data[categoryColumnIndex];
const platform = item.data[platformColumnIndex];
return {
id: name && category ? `${name} - ${category}` : crypto.randomUUID(),
name: name ?? "Unknown",
category,
playedWith: platform,
startsAt: new Date(item.scheduled),
};
});
};
Loading