Skip to content

Commit

Permalink
Cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
alkukampela committed Jan 25, 2021
1 parent c60b3bf commit 71905db
Show file tree
Hide file tree
Showing 10 changed files with 342 additions and 1,379 deletions.
13 changes: 0 additions & 13 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { getTotalScores } from './domain/game-score-manager';
import { initHand } from './domain/game-service';
import { playerExtractor } from './service/auth-middleware';
import { PlayerRequest } from './service/player-request';
import { sendRecoverySms } from './service/sms-recovery-service';
import { tokenForLoginId } from './service/token-service';
import { Card } from './types/card';
import { GameTypeChoice } from './types/game-type-choice';
import { RegisterPlayer } from './types/register-player';
import { SmsRecovery } from './types/sms-recovery';
import { TrickResponse } from './types/trick-response';
import cors from 'cors';
import * as dotenv from 'dotenv';
Expand Down Expand Up @@ -218,17 +216,6 @@ router.get(
}
);

router.post('/sms-recovery', (req: express.Request, res: express.Response) => {
const smsRecovery = req.body as SmsRecovery;
sendRecoverySms(smsRecovery)
.then(() => {
res.sendStatus(StatusCodes.NO_CONTENT);
})
.catch((err) => {
res.status(StatusCodes.BAD_REQUEST).send({ error: err.message });
});
});

wss.on('connection', (ws: WebSocketWithGameId, req: Request) => {
console.log('Client connected');

Expand Down
1,587 changes: 339 additions & 1,248 deletions src/bismarck-web/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/bismarck-web/src/components/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const Create = () => {
name="tab-group"
type="radio"
onClick={removePlayer}
checked
defaultChecked
/>
<input
id="four-players"
Expand Down
1 change: 0 additions & 1 deletion src/bismarck-web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ button,
input[type='submit'],
input[type='button'] {
border-radius: 5px;
box-shadow: var(--shadow-color) 0 0 2rem;
color: var(--whitelike);
border: 0;
outline: none;
Expand Down
12 changes: 0 additions & 12 deletions src/domain/game-creation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
storeGame,
storeHandStatute,
storeLoginIdForPlayer,
storeSmsRecoveries,
} from '../persistence/storage-service';

const initGameObject = (players: RegisterPlayer[]): Game => {
Expand Down Expand Up @@ -74,17 +73,6 @@ export const createGameAndInvitatePlayers = async (

storeHandStatute(handStatute, gameId);

storeSmsRecoveries(
[...playerIds.entries()].map((x) => {
return {
player: x[1].player,
canSendRecovery: true,
loginId: x[0],
};
}),
gameId
);

return {
id: gameId,
game,
Expand Down
2 changes: 1 addition & 1 deletion src/domain/hand-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const playerHasCardsOfSuit = (
return playersCards.some((card) => getSuit(card) === trickSuit);
};

export const setUpHand = async (gameId: string, game: Game) => {
export const setUpHand = async (gameId: string, game: Game): Promise<void> => {
initDeck(gameId);

const handStatute = getHandStatute(game, await getTrumpSuit(gameId));
Expand Down
7 changes: 0 additions & 7 deletions src/persistence/player-sms-recovery.ts

This file was deleted.

21 changes: 1 addition & 20 deletions src/persistence/storage-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CardContainer } from './card-container';
import { GamePlayer } from './game-player';
import { PlayerSmsRecovery } from './player-sms-recovery';
import { Trick } from './trick';
import { Game } from '../types/game';
import { HandStatute } from '../types/hand-statute';
Expand All @@ -15,8 +14,7 @@ type StorageType =
| Trick
| Game
| TrickScore[]
| GamePlayer
| PlayerSmsRecovery[];
| GamePlayer;

const ONE_DAY_EXPIRATION = 86400;

Expand Down Expand Up @@ -51,9 +49,6 @@ const getTrickScoresKey = (identifier: string): string =>
const getPlayerLoginIdKey = (identifier: string): string =>
`gameplayer:${identifier}`;

const getSmsRecoveryKey = (identifier: string): string =>
`smsrecovery:${identifier}`;

export const storeGame = (game: Game, identifier: string): void => {
store(getGamesKey(identifier), game);
};
Expand Down Expand Up @@ -145,17 +140,3 @@ export const fetchPlayerWithLoginId = async (
const result = await fetch(getPlayerLoginIdKey(loginId));
return JSON.parse(result);
};

export const storeSmsRecoveries = (
smsRecoveries: PlayerSmsRecovery[],
identifier: string
): void => {
store(getSmsRecoveryKey(identifier), smsRecoveries);
};

export const fetchSmsRecoveries = async (
identifier: string
): Promise<PlayerSmsRecovery[]> => {
const result = await fetch(getSmsRecoveryKey(identifier));
return JSON.parse(result);
};
69 changes: 0 additions & 69 deletions src/service/sms-recovery-service.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/types/sms-recovery.ts

This file was deleted.

0 comments on commit 71905db

Please sign in to comment.