taevas.xyz/api/infos/gamedev/itchio.ts
Taevas 98f4e9057d
Add itch.io to the GameDev Info
Surely something new will appear there soon
2025-04-14 17:37:27 +02:00

37 lines
1.2 KiB
TypeScript

import type { ItchioInfo } from "#Infos/GameDev/Itchio.tsx";
import type { Handler } from "../..";
export const itchio: Handler = async () => {
/** https://itch.io/docs/api/serverside#reference/profilegames-httpsitchioapi1keymy-games */
const response = await (await fetch(`https://itch.io/api/1/${process.env["API_ITCHIO"]}/my-games`)).json() as {
games: {
published_at?: string
title: string
short_text?: string
url: string
cover_url?: string
user: {
display_name: string
url: string
}
}[];
};
/** Do not show games that are unpublished (a game that is not public; still in development but has a page) */
const published_games = response.games.filter((game) => game.published_at);
const activity: ItchioInfo = {
user: {
name: published_games[0].user.display_name,
url: published_games[0].user.url
},
game: {
name: published_games[0].title,
description: published_games[0].short_text,
date: published_games[0].published_at!,
url: published_games[0].url,
cover_url: published_games[0].cover_url
}
};
return Response.json(activity, {status: 200});
};