diff --git a/src/lib/server/fetchData.ts b/src/lib/server/yukiotoko.ts similarity index 89% rename from src/lib/server/fetchData.ts rename to src/lib/server/yukiotoko.ts index dacd46e..c4c2702 100644 --- a/src/lib/server/fetchData.ts +++ b/src/lib/server/yukiotoko.ts @@ -2,7 +2,6 @@ import { env } from '$env/dynamic/private'; import type { APIPlayer, APIRoom, Player, Room } from '$lib/types'; import { fromVersionString, greaterThan } from '$lib/versioning'; import axios from 'axios'; -import type { FetchFunction } from 'vite'; function toPlayer(apiPlayer: APIPlayer): Player { return { @@ -21,7 +20,8 @@ function toPlayer(apiPlayer: APIPlayer): Player { function toRoom(apiRoom: APIRoom): Room { return { - id: apiRoom.roomId, + id: apiRoom.id, + roomId: apiRoom.roomId, createdAt: new Date(apiRoom.updatedAt), gameVersion: apiRoom.dataVersion, roomBattleRank: apiRoom.roomRanking, @@ -37,7 +37,7 @@ function filterRooms(rooms: Room[]): Room[] { ); } -export async function fetchData() { +export async function fetchRooms() { return { activeRooms: await axios .get('http://yukiotoko.chara.lol:9000/api/active', { @@ -55,3 +55,8 @@ export async function fetchData() { .then((result) => filterRooms(result.data.map((apiRoom) => toRoom(apiRoom)))) }; } + +// TODO! +// export async function fetchRoom(roomId: string): Promise { +// return new Promise() +// }