Skip to content

Commit

Permalink
Fixed production build
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail-kharrobi committed Nov 16, 2023
1 parent 98c20ac commit 343629e
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 647 deletions.
74 changes: 0 additions & 74 deletions backend/code/accountPickerCli.ts

This file was deleted.

4 changes: 2 additions & 2 deletions backend/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"build": "npm run db:generate && nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "npm run db:generate && nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
"start:prod": "node dist/main",
"db:generate": "prisma generate",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
Expand Down
162 changes: 0 additions & 162 deletions backend/code/seeder.ts

This file was deleted.

2 changes: 1 addition & 1 deletion backend/code/src/auth/utils/jwt_utils/jwt_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class JwtUtils {
{ username, sub: userId },
{
secret: JwtConsts.at_secret,
expiresIn: '15m',
expiresIn: '2h',
},
),
this.jwtService.signAsync(
Expand Down
16 changes: 8 additions & 8 deletions backend/code/src/game/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,26 +283,26 @@ export class Game {
}
private checkForWinner() {
if (this.p1Score >= 5) {
this.p1socket.emit('win', 'you win');
this.p2socket.emit('lose', 'you lose');
this.p1socket.emit('win', 'you won');
this.p2socket.emit('lose', 'you lost');
this.emitGameEnd('end');
}
if (this.p2Score >= 5) {
this.p2socket.emit('win', 'you win');
this.p1socket.emit('lose', 'you lose');
this.p2socket.emit('win', 'you won');
this.p1socket.emit('lose', 'you lost');
this.emitGameEnd('end');
}
}

private handleP1Disconnect = () => {
this.p2socket.emit('win', 'you win other player leave the game');
this.p1socket.emit('lose', 'you win other player leave the game');
this.p2socket.emit('win', 'you won, the other player left the game');
this.p1socket.emit('lose', 'you lost');
this.emitGameEnd('p1Leave');
};

private handleP2Disconnect = () => {
this.p1socket.emit('win', 'you win other player leave the game');
this.p2socket.emit('lose', 'you lost other player leave the game');
this.p1socket.emit('win', 'you won, the other player left the game');
this.p2socket.emit('lose', 'you lost');
this.emitGameEnd('p2Leave');
};

Expand Down
2 changes: 1 addition & 1 deletion backend/code/src/gateways/gateways.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface GameInvite {

@WebSocketGateway(3004, {
cors: {
origin: ['http://test.reversablecode.com:3001'],
origin: process.env.WS_CORS_ORIGIN?.split(',') || ['http://localhost:3001'],
},
transports: ['websocket'],
})
Expand Down
7 changes: 3 additions & 4 deletions backend/code/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import { GatewayAdapter } from './gateways/gateway-adapter';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const corsOptions = {
origin: [
'http://test.reversablecode.com:9000',
'http://test.reversablecode.com:8000',
'http://test.reversablecode.com:3000',
origin: process.env.CORS_ORIGIN?.split(',') || [
'http://localhost:8000',
'http://localhost:3000',
'http://142.93.161.63',
'http://164.92.243.105',
],
Expand Down
8 changes: 4 additions & 4 deletions backend/code/src/profile/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class ProfileService {
wonMatches === 0
? null
: wonMatches >= 100
? 2
: Math.floor(Math.log10(wonMatches));
? 2
: Math.floor(Math.log10(wonMatches));

return new ProfileDto({ ...user, achievement }, false);
}
Expand Down Expand Up @@ -58,8 +58,8 @@ export class ProfileService {
wonMatches === 0
? null
: wonMatches >= 100
? 2
: Math.floor(Math.log10(wonMatches));
? 2
: Math.floor(Math.log10(wonMatches));
return new ProfileDto({ ...user, achievement }, true);
}

Expand Down
27 changes: 13 additions & 14 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ services :
networks:
- pongnet
init: true
restart: always

database:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: test
volumes:
- database:/var/lib/postgresql/data
networks:
- pongnet
restart: always

backend:
build:
Expand All @@ -32,7 +20,6 @@ services :
- pongnet
depends_on:
- database
restart: always
ports:
- 3001:3001
- 3004:3004
Expand All @@ -55,15 +42,27 @@ services :
init: true
restart: always

database:
image: postgres
restart: always
env_file:
- ./.env
volumes:
- database:/var/lib/postgresql/data
networks:
- pongnet

migration:
build:
context: ./backend/code/prisma
dockerfile: Dockerfile
image: prisma_migration:local
env_file:
- ./.env
networks:
- pongnet
depends_on:
- backend
- database

volumes:
front:
Expand Down
Loading

0 comments on commit 343629e

Please sign in to comment.