Compare commits

...

2 Commits

Author SHA1 Message Date
e6a38e2a0b other: rename file 2024-12-31 21:36:08 -08:00
26d216d4cb chore: pass the internal room id and the room id 2024-12-31 21:35:58 -08:00
2 changed files with 11 additions and 4 deletions

View File

@ -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<APIRoom[]>('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<Room> {
// return new Promise()
// }

View File

@ -56,7 +56,8 @@ export interface APIPlayer {
}
export interface Room {
id: number;
id: string;
roomId: number;
createdAt: Date;
gameVersion: string;
roomBattleRank: number;
@ -66,6 +67,7 @@ export interface Room {
}
export interface APIRoom {
id: string;
userId: string;
roomId: number;
dataVersion: string;