Skip to content

Commit

Permalink
fix: fallback values for arr data
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirasaki committed Nov 12, 2024
1 parent b297d37 commit 87603be
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/resolvers/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ import type {

export const transformGrantResponse = (response: GrantsResponse): ClientGrantsResponse => {
return {
banlist: response.tokens.banlist.map((token) => ({
banlist: response.tokens.banlist?.map((token) => ({
createdAt: new Date(token.created_at),
resource: {
id: token.resource.id,
identifier: token.resource.identifier,
objectId: token.resource.object_id,
},
})),
server: response.tokens.server.map((token) => ({
})) ?? [],
server: response.tokens.server?.map((token) => ({
createdAt: new Date(token.created_at),
resource: {
id: token.resource.id,
identifier: token.resource.identifier,
objectId: token.resource.object_id,
gameserverId: token.resource.gameserver_id,
},
})),
})) ?? [],
};
};

Expand Down Expand Up @@ -78,15 +78,15 @@ export const transformGameServerDetails = (
os: responseData.host.os,
queryPort: responseData.host.query_port,
},
mods: responseData.mods.map((mod) => ({
mods: responseData.mods?.map((mod) => ({
fileId: mod.file_id,
name: mod.name,
})),
})) ?? [],
};
};

export const transformBanListResponse = (response: ListBansResponse): ClientListBansResponse => {
return response.entries.map((ban) => ({
return response.entries?.map((ban) => ({
id: ban.id,
reason: ban.reason,
expiresAt: ban.expires_at ? new Date(ban.expires_at) : null,
Expand All @@ -95,7 +95,7 @@ export const transformBanListResponse = (response: ListBansResponse): ClientList
status: ban.status,
identifier: ban.identifier,
links: ban.links,
}));
})) ?? [];
};

export const transformServerInfoResponse = (response: ServerInfoResponse): ClientServerInfoResponse => {
Expand Down Expand Up @@ -184,7 +184,7 @@ export const transformServerStatisticsResponse = (
};

export const transformPlayerListResponse = (response: PlayerListResponse): ClientPlayerListResponse => {
return response.sessions.map((session) => ({
return response.sessions?.map((session) => ({
id: session.id,
cftoolsId: session.cftools_id,
connection: {
Expand Down Expand Up @@ -258,7 +258,7 @@ export const transformPlayerListResponse = (response: PlayerListResponse): Clien
longestShot: session.stats.longest_shot,
suicides: session.stats.suicides,
},
}));
})) ?? [];
};

export const transformGameLabsActionsResponse = (response: GameLabsActionsResponse): ClientGameLabsActionsResponse => {
Expand All @@ -278,7 +278,7 @@ export const transformGameLabsEntityVehiclesResponse = (
};

export const transformPriorityQueueResponse = (response: PriorityQueueResponse): ClientPriorityQueueResponse => {
return response.entries.map((entry) => ({
return response.entries?.map((entry) => ({
createdAt: new Date(entry.created_at),
creator: {
cftoolsId: entry.creator.cftools_id,
Expand All @@ -294,11 +294,11 @@ export const transformPriorityQueueResponse = (response: PriorityQueueResponse):
cftoolsId: entry.user.cftools_id,
},
uuid: entry.uuid,
}));
})) ?? [];
};

export const transformWhitelistResponse = (response: WhitelistResponse): ClientWhitelistResponse => {
return response.entries.map((entry) => ({
return response.entries?.map((entry) => ({
createdAt: new Date(entry.created_at),
creator: {
cftoolsId: entry.creator.cftools_id,
Expand All @@ -314,11 +314,11 @@ export const transformWhitelistResponse = (response: WhitelistResponse): ClientW
cftoolsId: entry.user.cftools_id,
},
uuid: entry.uuid,
}));
})) ?? [];
};

export const transformLeaderboardResponse = (response: LeaderboardResponse): ClientLeaderboardResponse => {
return response.leaderboard.map((entry) => ({
return response.leaderboard?.map((entry) => ({
cftoolsId: entry.cftools_id,
deaths: entry.deaths,
environmentDeaths: entry.environment_deaths,
Expand All @@ -331,7 +331,7 @@ export const transformLeaderboardResponse = (response: LeaderboardResponse): Cli
playtime: entry.playtime,
rank: entry.rank,
suicides: entry.suicides,
}));
})) ?? [];
};

export const transformPlayerStatsResponse = (
Expand Down

0 comments on commit 87603be

Please sign in to comment.