This commit is contained in:
@ -9,27 +9,25 @@ export const GET: APIRoute = async ({ request }) => {
|
||||
|
||||
const teams = await db.getTeamsFull({});
|
||||
|
||||
const response = [];
|
||||
const response = {} as Record<number, any>;
|
||||
for (const team of teams) {
|
||||
response.push({
|
||||
name: team.team.name,
|
||||
color: team.team.color,
|
||||
lastJoined: team.team.lastJoined ? new Date(team.team.lastJoined).getTime() : null,
|
||||
strikeWeight: team.strikeWeight ?? 0,
|
||||
memberOne: team.memberOne
|
||||
? {
|
||||
uuid: team.memberOne.uuid,
|
||||
dead: team.memberOneDeath != null
|
||||
}
|
||||
: null,
|
||||
memberTwo: team.memberTwo
|
||||
? {
|
||||
uuid: team.memberTwo.uuid,
|
||||
dead: team.memberTwoDeath != null
|
||||
}
|
||||
: null
|
||||
});
|
||||
if (response[team.team.id] === undefined) {
|
||||
response[team.team.id] = {
|
||||
name: team.team.name,
|
||||
color: team.team.color,
|
||||
lastJoined: team.team.lastJoined ? new Date(team.team.lastJoined).getTime() : null,
|
||||
strikeWeight: team.strikeWeight ?? 0,
|
||||
users: []
|
||||
};
|
||||
}
|
||||
|
||||
if (team.user) {
|
||||
response[team.team.id].users.push({
|
||||
uuid: team.user.uuid,
|
||||
dead: team.death != null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify(response));
|
||||
return new Response(JSON.stringify(Object.values(response)));
|
||||
};
|
||||
|
Reference in New Issue
Block a user