Skip to content

Commit

Permalink
refactor(server): Improve typings in API code
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed May 7, 2020
1 parent ca819d9 commit af72f03
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/server/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export const createApiServer = ({
lobbyConfig,
generateCredentials,
}: {
db: any;
games: any;
db: StorageAPI.Sync | StorageAPI.Async;
games: Game[];
lobbyConfig?: Server.LobbyConfig;
generateCredentials?: Server.GenerateCredentials;
}) => {
Expand Down Expand Up @@ -134,7 +134,7 @@ export const addApiToServer = ({
if (!metadata.unlisted) {
rooms.push({
gameID,
players: Object.values(metadata.players).map((player: any) => {
players: Object.values(metadata.players).map(player => {
// strip away credentials
const { credentials, ...strippedInfo } = player;
return strippedInfo;
Expand All @@ -158,7 +158,7 @@ export const addApiToServer = ({
}
const strippedRoom = {
roomID: gameID,
players: Object.values(metadata.players).map((player: any) => {
players: Object.values(metadata.players).map(player => {
const { credentials, ...strippedInfo } = player;
return strippedInfo;
}),
Expand Down Expand Up @@ -228,7 +228,7 @@ export const addApiToServer = ({

delete metadata.players[playerID].name;
delete metadata.players[playerID].credentials;
if (Object.values(metadata.players).some((val: any) => val.name)) {
if (Object.values(metadata.players).some(player => player.name)) {
await db.setMetadata(gameID, metadata);
} else {
// remove room
Expand Down Expand Up @@ -289,7 +289,7 @@ export const addApiToServer = ({
};
});

const updatePlayerMetadata = async ctx => {
const updatePlayerMetadata = async (ctx: Koa.Context) => {
const gameID = ctx.params.id;
const playerID = ctx.request.body.playerID;
const credentials = ctx.request.body.credentials;
Expand Down

0 comments on commit af72f03

Please sign in to comment.