Browse Source

simplified structure

master
nicolas-arnaud 2 years ago
parent
commit
2411261da5
  1. 35
      .env_sample
  2. 6
      .gitattributes
  3. 2
      Makefile
  4. 14
      Makesudo
  5. 5
      back.dockerfile
  6. 0
      back/.eslintrc.js
  7. 0
      back/.gitignore
  8. 10
      back/Dockerfile
  9. 31
      back/entrypoint.sh
  10. 0
      back/nest-cli.json
  11. 0
      back/package-lock.json
  12. 0
      back/package.json
  13. 36
      back/src/app.module.ts
  14. 0
      back/src/auth/42-auth.guard.ts
  15. 0
      back/src/auth/42.decorator.ts
  16. 7
      back/src/auth/42.strategy.ts
  17. 0
      back/src/auth/auth.controller.ts
  18. 0
      back/src/auth/auth.module.ts
  19. 0
      back/src/auth/auth.service.ts
  20. 0
      back/src/auth/mails/confirm.hbs
  21. 0
      back/src/auth/mails/confirmed.hbs
  22. 0
      back/src/auth/session.serializer.ts
  23. 3
      back/src/chat/chat.controller.ts
  24. 2
      back/src/chat/chat.gateway.ts
  25. 0
      back/src/chat/chat.module.ts
  26. 0
      back/src/chat/chat.service.ts
  27. 0
      back/src/chat/dto/connection.dto.ts
  28. 0
      back/src/chat/dto/create-channel.dto.ts
  29. 0
      back/src/chat/dto/create-message.dto.ts
  30. 0
      back/src/chat/dto/kickUser.dto.ts
  31. 0
      back/src/chat/dto/update-channel.dto.ts
  32. 0
      back/src/chat/dto/updateUser.dto.ts
  33. 0
      back/src/chat/entity/channel.entity.ts
  34. 0
      back/src/chat/entity/connection.entity.ts
  35. 0
      back/src/chat/entity/dm.entity.ts
  36. 0
      back/src/chat/entity/message.entity.ts
  37. 0
      back/src/chat/message.service.ts
  38. 0
      back/src/main.ts
  39. 0
      back/src/pong/dtos/GameCreationDtoValidated.ts
  40. 0
      back/src/pong/dtos/GameInfo.ts
  41. 0
      back/src/pong/dtos/GameUpdate.ts
  42. 0
      back/src/pong/dtos/MapDtoValidated.ts
  43. 0
      back/src/pong/dtos/MatchmakingDto.ts
  44. 0
      back/src/pong/dtos/MatchmakingDtoValidated.ts
  45. 0
      back/src/pong/dtos/PointDtoValidated.ts
  46. 0
      back/src/pong/dtos/RectDtoValidated.ts
  47. 0
      back/src/pong/dtos/StringDto.ts
  48. 0
      back/src/pong/dtos/StringDtoValidated.ts
  49. 0
      back/src/pong/dtos/UserDto.ts
  50. 0
      back/src/pong/entity/result.entity.ts
  51. 0
      back/src/pong/game/Ball.ts
  52. 0
      back/src/pong/game/Game.ts
  53. 0
      back/src/pong/game/Games.ts
  54. 0
      back/src/pong/game/MatchmakingQueue.ts
  55. 0
      back/src/pong/game/Paddle.ts
  56. 0
      back/src/pong/game/Player.ts
  57. 0
      back/src/pong/game/constants.ts
  58. 0
      back/src/pong/game/utils.ts
  59. 0
      back/src/pong/pong.controller.ts
  60. 0
      back/src/pong/pong.gateway.ts
  61. 0
      back/src/pong/pong.module.ts
  62. 0
      back/src/pong/pong.service.ts
  63. 0
      back/src/types.d.ts
  64. 0
      back/src/users/dto/user.dto.ts
  65. 0
      back/src/users/entity/user.entity.ts
  66. 0
      back/src/users/users.controller.ts
  67. 0
      back/src/users/users.module.ts
  68. 0
      back/src/users/users.service.ts
  69. 0
      back/tsconfig.build.json
  70. 0
      back/tsconfig.json
  71. 73
      back/volume/README.md
  72. 53
      back/volume/src/app.module.ts
  73. 12
      docker-compose.yml
  74. 5
      front.dockerfile
  75. 0
      front/.gitignore
  76. 13
      front/entrypoint.sh
  77. 0
      front/index.html
  78. 0
      front/package-lock.json
  79. 0
      front/package.json
  80. 0
      front/public/audio/edge_hit.wav
  81. 0
      front/public/audio/paddle_hit.wav
  82. 0
      front/public/audio/score.wav
  83. 0
      front/public/global.css
  84. 0
      front/public/img/chat.png
  85. 0
      front/public/img/close.png
  86. 0
      front/public/img/pog.jpg
  87. 0
      front/public/img/pong.png
  88. 0
      front/public/img/send.png
  89. 0
      front/public/vite.svg
  90. 0
      front/src/App.svelte
  91. 0
      front/src/Auth.ts
  92. 0
      front/src/app.d.ts
  93. 0
      front/src/components/Alert/Alert.svelte
  94. 0
      front/src/components/Alert/content.ts
  95. 11
      front/src/components/Channels.svelte
  96. 6
      front/src/components/Chat.svelte
  97. 0
      front/src/components/Friends.svelte
  98. 0
      front/src/components/Leaderboard.svelte
  99. 0
      front/src/components/MatchHistory.svelte
  100. 8
      front/src/components/NavBar.svelte

35
.env_sample

@ -1,23 +1,30 @@
POSTGRES_HOST=postgres ### BACK ###
POSTGRES_PORT=5432
POSTGRES_USER=postgres_usr
POSTGRES_PASSWORD=postgres_pw
POSTGRES_DB=transcendence
MAIL_USER=vaganiwast@gmail.com
MAIL_PASSWORD=
FRONT_FPS=144
HOST=localhost HOST=localhost
VITE_HOST=localhost
FRONT_PORT=80 FRONT_PORT=80
BACK_PORT=3001 BACK_PORT=3001
HASH_SALT=10 HASH_SALT=10
JWT_SECRET= ### FRONT ###
JWT_EXPIRATION_TIME=900 VITE_HOST=localhost
VITE_BACK_PORT=3001
### GAME ###
VITE_FRONT_FPS=144
### 2FA ###
MAIL_USER=vaganiwast@gmail.com
MAIL_PASSWORD=
### AUTH ###
FT_OAUTH_CLIENT_ID= FT_OAUTH_CLIENT_ID=
FT_OAUTH_CLIENT_SECRET= FT_OAUTH_CLIENT_SECRET=
FT_OAUTH_CALLBACK_URL=http://localhost:3001/log/inReturn FT_OAUTH_CALLBACK_URL=http://localhost:3001/log/inReturn
JWT_SECRET=test
JWT_EXPIRATION_TIME=900
### DB ###
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_USER=postgres_usr
POSTGRES_PASSWORD=postgres_pw
POSTGRES_DB=transcendence

6
.gitattributes

@ -0,0 +1,6 @@
*.ts text=auto eol=lf
*.svelte text=auto eol=lf
*.yml text=auto eol=lf
*.json text=auto eol=lf
*.html text=auto eol=lf
*.xml text=auto eol=lf

2
Makefile

@ -21,7 +21,7 @@ clean: stop
docker system prune -f docker system prune -f
fclean: stop fclean: stop
rm -rf */volume/node_modules rm -rf */node_modules
docker system prune -af --volumes docker system prune -af --volumes
re: fclean dev re: fclean dev

14
Makesudo

@ -4,27 +4,27 @@ USER = gavaniwast
all: clean dev all: clean dev
prod: prod:
sudo NODE_ENV="production" docker compose -f docker-compose.yml up --build sudo docker-compose up --build
dev: dev:
sudo NODE_ENV="development" docker compose -f docker-compose.yml up --build sudo docker-compose up --build
check: check:
sudo NODE_ENV="check" docker compose -f docker-compose.yml run back --build sudo NODE_ENV="check" docker-compose run back --build
sudo NODE_ENV="check" docker compose -f docker-compose.yml run front --build sudo NODE_ENV="check" docker-compose run front --build
sudo docker compose -f docker-compose.yml down sudo docker compose -f docker-compose.yml down
debug: debug:
sudo NODE_ENV="debug" BUILDKIT_PROGRESS=plain docker compose -f docker-compose.yml up --build sudo NODE_ENV="debug" BUILDKIT_PROGRESS=plain docker-compose up --build
stop: stop:
sudo docker compose -f docker-compose.yml down sudo docker-compose down
clean: stop clean: stop
sudo docker system prune -f sudo docker system prune -f
fclean: stop fclean: stop
rm */volume/node_modules sudo rm -rf */node_modules
sudo docker system prune -af --volumes sudo docker system prune -af --volumes
re: fclean dev re: fclean dev

5
back.dockerfile

@ -0,0 +1,5 @@
FROM alpine:3.15
RUN apk update && apk upgrade && apk add npm && npm install -g @nestjs/cli
WORKDIR /var/www/html
ENTRYPOINT npm install && npm run dev

0
back/volume/.eslintrc.js → back/.eslintrc.js

0
back/volume/.gitignore → back/.gitignore

10
back/Dockerfile

@ -1,10 +0,0 @@
FROM alpine:3.15
RUN apk update && apk upgrade && apk add npm \
&& npm install -g @nestjs/cli
WORKDIR /var/www/html
COPY entrypoint.sh /tmp/entrypoint.sh
ENTRYPOINT ["sh", "/tmp/entrypoint.sh"]

31
back/entrypoint.sh

@ -1,31 +0,0 @@
npm install;
cat >.env <<EOF
POSTGRES_HOST=$POSTGRES_HOST
POSTGRES_PORT=$POSTGRES_PORT
POSTGRES_USER=$POSTGRES_USER
POSTGRES_PASSWORD=$POSTGRES_PASSWORD
POSTGRES_DB=$POSTGRES_DB
MAIL_USER=$MAIL_USER
MAIL_PASSWORD=$MAIL_PASSWORD
HOST=$HOST
FRONT_PORT=$FRONT_PORT
BACK_PORT=$BACK_PORT
HASH_SALT=$HASH_SALT
JWT_SECRET=$JWT_SECRET
JWT_EXPIRATION_TIME=$JWT_EXPIRATION_TIME
FT_OAUTH_CLIENT_ID=$FT_OAUTH_CLIENT_ID
FT_OAUTH_CLIENT_SECRET=$FT_OAUTH_CLIENT_SECRET
FT_OAUTH_CALLBACK_URL=$FT_OAUTH_CALLBACK_URL
EOF
if [[ $NODE_ENV == "debug" ]]; then
npm run start:debug;
elif [[ $NODE_ENV == "check" ]]; then
npm run format && npm run lint; echo "=== FINISH ===";
else
npm run dev;
fi;

0
back/volume/nest-cli.json → back/nest-cli.json

0
back/volume/package-lock.json → back/package-lock.json

0
back/volume/package.json → back/package.json

36
back/src/app.module.ts

@ -0,0 +1,36 @@
import { Module } from '@nestjs/common'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { TypeOrmModule } from '@nestjs/typeorm'
import * as Joi from 'joi'
import { ScheduleModule } from '@nestjs/schedule'
import { AuthModule } from './auth/auth.module'
import { ChatModule } from './chat/chat.module'
import { PongModule } from './pong/pong.module'
import { UsersModule } from './users/users.module'
@Module({
imports: [
ScheduleModule.forRoot(),
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
type: 'postgres',
host: process.env.POSTGRES_HOST || 'localhost',
port: (process.env.POSTGRES_PORT || 5432) as number,
username: process.env.POSTGRES_USER || 'postgres',
password: process.env.POSTGRES_PASSWORD || 'postgres',
database: process.env.POSTGRES_DB || 'postgres',
jwt_secret: process.env.JWT_SECRET || 'secret',
autoLoadEntities: true,
synchronize: true
})
}),
AuthModule,
ChatModule,
PongModule,
UsersModule
]
})
export class AppModule {}

0
back/volume/src/auth/42-auth.guard.ts → back/src/auth/42-auth.guard.ts

0
back/volume/src/auth/42.decorator.ts → back/src/auth/42.decorator.ts

7
back/volume/src/auth/42.strategy.ts → back/src/auth/42.strategy.ts

@ -11,13 +11,12 @@ import { User } from 'src/users/entity/user.entity'
@Injectable() @Injectable()
export class FtStrategy extends PassportStrategy(Strategy, '42') { export class FtStrategy extends PassportStrategy(Strategy, '42') {
constructor ( constructor (
private readonly configService: ConfigService,
private readonly usersService: UsersService private readonly usersService: UsersService
) { ) {
super({ super({
clientID: configService.get<string>('FT_OAUTH_CLIENT_ID'), clientID: process.env.FT_OAUTH_CLIENT_ID,
clientSecret: configService.get<string>('FT_OAUTH_CLIENT_SECRET'), clientSecret: process.env.FT_OAUTH_CLIENT_SECRET,
callbackURL: configService.get<string>('FT_OAUTH_CALLBACK_URL'), callbackURL: process.env.FT_OAUTH_CALLBACK_URL,
passReqToCallback: true passReqToCallback: true
}) })
} }

0
back/volume/src/auth/auth.controller.ts → back/src/auth/auth.controller.ts

0
back/volume/src/auth/auth.module.ts → back/src/auth/auth.module.ts

0
back/volume/src/auth/auth.service.ts → back/src/auth/auth.service.ts

0
back/volume/src/auth/mails/confirm.hbs → back/src/auth/mails/confirm.hbs

0
back/volume/src/auth/mails/confirmed.hbs → back/src/auth/mails/confirmed.hbs

0
back/volume/src/auth/session.serializer.ts → back/src/auth/session.serializer.ts

3
back/volume/src/chat/chat.controller.ts → back/src/chat/chat.controller.ts

@ -121,6 +121,9 @@ export class ChatController {
@Profile42() profile: Profile @Profile42() profile: Profile
): Promise<void> { ): Promise<void> {
const channel = await this.channelService.getFullChannel(id) const channel = await this.channelService.getFullChannel(id)
if (await this.channelService.isOwner(channel.id, target.id)) {
throw new BadRequestException('The owner cannot be demoted')
}
if (!(await this.channelService.isOwner(channel.id, +profile.id))) { if (!(await this.channelService.isOwner(channel.id, +profile.id))) {
throw new BadRequestException('You are not the owner of this channel') throw new BadRequestException('You are not the owner of this channel')
} }

2
back/volume/src/chat/chat.gateway.ts → back/src/chat/chat.gateway.ts

@ -84,7 +84,7 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect {
conUser.user = user.ftId; conUser.user = user.ftId;
conUser.channel = channel.id; conUser.channel = channel.id;
conUser.socket = socket.id; conUser.socket = socket.id;
const test = await this.connectedUserRepository.save(conUser); await this.connectedUserRepository.save(conUser);
await socket.join(channel.id.toString()); await socket.join(channel.id.toString());
this.server.to(socket.id).emit('messages', messages); this.server.to(socket.id).emit('messages', messages);
} }

0
back/volume/src/chat/chat.module.ts → back/src/chat/chat.module.ts

0
back/volume/src/chat/chat.service.ts → back/src/chat/chat.service.ts

0
back/volume/src/chat/dto/connection.dto.ts → back/src/chat/dto/connection.dto.ts

0
back/volume/src/chat/dto/create-channel.dto.ts → back/src/chat/dto/create-channel.dto.ts

0
back/volume/src/chat/dto/create-message.dto.ts → back/src/chat/dto/create-message.dto.ts

0
back/volume/src/chat/dto/kickUser.dto.ts → back/src/chat/dto/kickUser.dto.ts

0
back/volume/src/chat/dto/update-channel.dto.ts → back/src/chat/dto/update-channel.dto.ts

0
back/volume/src/chat/dto/updateUser.dto.ts → back/src/chat/dto/updateUser.dto.ts

0
back/volume/src/chat/entity/channel.entity.ts → back/src/chat/entity/channel.entity.ts

0
back/volume/src/chat/entity/connection.entity.ts → back/src/chat/entity/connection.entity.ts

0
back/volume/src/chat/entity/dm.entity.ts → back/src/chat/entity/dm.entity.ts

0
back/volume/src/chat/entity/message.entity.ts → back/src/chat/entity/message.entity.ts

0
back/volume/src/chat/message.service.ts → back/src/chat/message.service.ts

0
back/volume/src/main.ts → back/src/main.ts

0
back/volume/src/pong/dtos/GameCreationDtoValidated.ts → back/src/pong/dtos/GameCreationDtoValidated.ts

0
back/volume/src/pong/dtos/GameInfo.ts → back/src/pong/dtos/GameInfo.ts

0
back/volume/src/pong/dtos/GameUpdate.ts → back/src/pong/dtos/GameUpdate.ts

0
back/volume/src/pong/dtos/MapDtoValidated.ts → back/src/pong/dtos/MapDtoValidated.ts

0
back/volume/src/pong/dtos/MatchmakingDto.ts → back/src/pong/dtos/MatchmakingDto.ts

0
back/volume/src/pong/dtos/MatchmakingDtoValidated.ts → back/src/pong/dtos/MatchmakingDtoValidated.ts

0
back/volume/src/pong/dtos/PointDtoValidated.ts → back/src/pong/dtos/PointDtoValidated.ts

0
back/volume/src/pong/dtos/RectDtoValidated.ts → back/src/pong/dtos/RectDtoValidated.ts

0
back/volume/src/pong/dtos/StringDto.ts → back/src/pong/dtos/StringDto.ts

0
back/volume/src/pong/dtos/StringDtoValidated.ts → back/src/pong/dtos/StringDtoValidated.ts

0
back/volume/src/pong/dtos/UserDto.ts → back/src/pong/dtos/UserDto.ts

0
back/volume/src/pong/entity/result.entity.ts → back/src/pong/entity/result.entity.ts

0
back/volume/src/pong/game/Ball.ts → back/src/pong/game/Ball.ts

0
back/volume/src/pong/game/Game.ts → back/src/pong/game/Game.ts

0
back/volume/src/pong/game/Games.ts → back/src/pong/game/Games.ts

0
back/volume/src/pong/game/MatchmakingQueue.ts → back/src/pong/game/MatchmakingQueue.ts

0
back/volume/src/pong/game/Paddle.ts → back/src/pong/game/Paddle.ts

0
back/volume/src/pong/game/Player.ts → back/src/pong/game/Player.ts

0
back/volume/src/pong/game/constants.ts → back/src/pong/game/constants.ts

0
back/volume/src/pong/game/utils.ts → back/src/pong/game/utils.ts

0
back/volume/src/pong/pong.controller.ts → back/src/pong/pong.controller.ts

0
back/volume/src/pong/pong.gateway.ts → back/src/pong/pong.gateway.ts

0
back/volume/src/pong/pong.module.ts → back/src/pong/pong.module.ts

0
back/volume/src/pong/pong.service.ts → back/src/pong/pong.service.ts

0
back/volume/src/types.d.ts → back/src/types.d.ts

0
back/volume/src/users/dto/user.dto.ts → back/src/users/dto/user.dto.ts

0
back/volume/src/users/entity/user.entity.ts → back/src/users/entity/user.entity.ts

0
back/volume/src/users/users.controller.ts → back/src/users/users.controller.ts

0
back/volume/src/users/users.module.ts → back/src/users/users.module.ts

0
back/volume/src/users/users.service.ts → back/src/users/users.service.ts

0
back/volume/tsconfig.build.json → back/tsconfig.build.json

0
back/volume/tsconfig.json → back/tsconfig.json

73
back/volume/README.md

@ -1,73 +0,0 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
</p>
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Installation
```bash
$ npm install
```
## Running the app
```bash
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
```
## Test
```bash
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
```
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).

53
back/volume/src/app.module.ts

@ -1,53 +0,0 @@
import { Module } from '@nestjs/common'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { TypeOrmModule } from '@nestjs/typeorm'
import * as Joi from 'joi'
import { ScheduleModule } from '@nestjs/schedule'
import { AuthModule } from './auth/auth.module'
import { ChatModule } from './chat/chat.module'
import { PongModule } from './pong/pong.module'
import { UsersModule } from './users/users.module'
@Module({
imports: [
ScheduleModule.forRoot(),
ConfigModule.forRoot({
validationSchema: Joi.object({
POSTGRES_HOST: Joi.string().required(),
POSTGRES_PORT: Joi.number().required(),
POSTGRES_USER: Joi.string().required(),
POSTGRES_PASSWORD: Joi.string().required(),
POSTGRES_DB: Joi.string().required(),
MAIL_USER: Joi.string().required(),
MAIL_PASSWORD: Joi.string().required(),
JWT_SECRET: Joi.string().required(),
JWT_EXPIRATION_TIME: Joi.string().required(),
HOST: Joi.string().required(),
FRONT_PORT: Joi.number().required(),
BACK_PORT: Joi.number().required(),
HASH_SALT: Joi.number().required()
})
}),
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
type: 'postgres',
host: configService.get<string>('POSTGRES_HOST'),
port: configService.get<number>('POSTGRES_PORT'),
username: configService.get<string>('POSTGRES_USER'),
password: configService.get<string>('POSTGRES_PASSWORD'),
database: configService.get<string>('POSTGRES_DB'),
jwt_secret: configService.get<string>('JWT_SECRET'),
autoLoadEntities: true,
synchronize: true
})
}),
AuthModule,
ChatModule,
PongModule,
UsersModule
]
})
export class AppModule {}

12
docker-compose.yml

@ -6,25 +6,29 @@ networks:
services: services:
front: front:
container_name: front container_name: front
build: front/ build:
context: ./
dockerfile: front.dockerfile
env_file: .env env_file: .env
environment: environment:
- NODE_ENV=${NODE_ENV} - NODE_ENV=${NODE_ENV}
depends_on: [postgres, back] depends_on: [postgres, back]
ports: [80:80] ports: [80:80]
volumes: [./front/volume:/var/www/html] volumes: [./front:/var/www/html]
networks: [transcendence] networks: [transcendence]
restart: on-failure restart: on-failure
back: back:
container_name: back container_name: back
build: back/ build:
context: ./
dockerfile: back.dockerfile
env_file: .env env_file: .env
environment: environment:
- NODE_ENV=${NODE_ENV} - NODE_ENV=${NODE_ENV}
depends_on: [postgres] depends_on: [postgres]
ports: [3001:3001] ports: [3001:3001]
networks: [transcendence] networks: [transcendence]
volumes: [./back/volume:/var/www/html] volumes: [./back:/var/www/html]
restart: on-failure restart: on-failure
postgres: postgres:
container_name: postgres container_name: postgres

5
front/Dockerfile → front.dockerfile

@ -1,8 +1,5 @@
FROM alpine:3.15 FROM alpine:3.15
RUN apk update && apk upgrade && apk add npm RUN apk update && apk upgrade && apk add npm
WORKDIR /var/www/html WORKDIR /var/www/html
COPY entrypoint.sh /tmp/entrypoint.sh ENTRYPOINT npm install && npm run dev
ENTRYPOINT ["sh", "/tmp/entrypoint.sh"]

0
front/volume/.gitignore → front/.gitignore

13
front/entrypoint.sh

@ -1,13 +0,0 @@
npm install;
cat >.env <<EOF
VITE_FRONT_FPS=$FRONT_FPS
VITE_HOST=$HOST
VITE_BACK_PORT=$BACK_PORT
EOF
npm install;
if [[ $NODE_ENV == "check" ]]; then
npm run format && npm run check; echo "=== FINISH ==="
else
npm run dev;
fi;

0
front/volume/index.html → front/index.html

0
front/volume/package-lock.json → front/package-lock.json

0
front/volume/package.json → front/package.json

0
front/volume/public/audio/edge_hit.wav → front/public/audio/edge_hit.wav

0
front/volume/public/audio/paddle_hit.wav → front/public/audio/paddle_hit.wav

0
front/volume/public/audio/score.wav → front/public/audio/score.wav

0
front/volume/public/global.css → front/public/global.css

0
front/volume/public/img/chat.png → front/public/img/chat.png

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

0
front/volume/public/img/close.png → front/public/img/close.png

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 342 B

0
front/volume/public/img/pog.jpg → front/public/img/pog.jpg

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

0
front/volume/public/img/pong.png → front/public/img/pong.png

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

0
front/volume/public/img/send.png → front/public/img/send.png

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 858 B

0
front/volume/public/vite.svg → front/public/vite.svg

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

0
front/volume/src/App.svelte → front/src/App.svelte

0
front/volume/src/Auth.ts → front/src/Auth.ts

0
front/volume/src/app.d.ts → front/src/app.d.ts

0
front/volume/src/components/Alert/Alert.svelte → front/src/components/Alert/Alert.svelte

0
front/volume/src/components/Alert/content.ts → front/src/components/Alert/content.ts

11
front/volume/src/components/Channels.svelte → front/src/components/Channels.svelte

@ -1,5 +1,12 @@
<script lang="ts" context="module"> <script lang="ts" context="module">
import { content, show_popup } from './Alert/content' import { content, show_popup } from './Alert/content'
import { onMount } from "svelte";
import { API_URL, store } from "../Auth";
import type User from "./Profile.svelte";
import { APPSTATE } from "../App.svelte";
export let appState: string;
export let setAppState: (newState: APPSTATE | string) => void;
export interface ChannelsType { export interface ChannelsType {
id: number; id: number;
@ -16,9 +23,6 @@
author: User; author: User;
text: string; text: string;
} }
import { onMount } from "svelte";
import { API_URL, store } from "../Auth";
import type User from "./Profile.svelte";
export async function formatChannelNames(channel: Array<ChannelsType>): Promise<void> { export async function formatChannelNames(channel: Array<ChannelsType>): Promise<void> {
const res = await fetch(API_URL + "/users/all", { const res = await fetch(API_URL + "/users/all", {
@ -60,6 +64,7 @@
} }
} }
} }
</script> </script>
<script lang="ts"> <script lang="ts">

6
front/volume/src/components/Chat.svelte → front/src/components/Chat.svelte

@ -6,6 +6,7 @@
import { APPSTATE } from "../App.svelte"; import { APPSTATE } from "../App.svelte";
import { formatChannelNames, type ChannelsType, type chatMessagesType } from "./Channels.svelte"; import { formatChannelNames, type ChannelsType, type chatMessagesType } from "./Channels.svelte";
import type User from "./Profile.svelte"; import type User from "./Profile.svelte";
</script> </script>
<script lang="ts"> <script lang="ts">
@ -41,9 +42,7 @@
} }
onMount(async () => { onMount(async () => {
socket = io( socket = io(API_URL);
"http://" + (import.meta.env.VITE_HOST ?? "localhost") + ":3001"
);
socket.connect(); socket.connect();
await getCurrentChannel(); await getCurrentChannel();
if (!channel) setAppState(APPSTATE.CHANNELS); if (!channel) setAppState(APPSTATE.CHANNELS);
@ -129,7 +128,6 @@
} }
} }
}; };
//--------------------------------------------------------------------------------/ //--------------------------------------------------------------------------------/
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();

0
front/volume/src/components/Friends.svelte → front/src/components/Friends.svelte

0
front/volume/src/components/Leaderboard.svelte → front/src/components/Leaderboard.svelte

0
front/volume/src/components/MatchHistory.svelte → front/src/components/MatchHistory.svelte

8
front/volume/src/components/NavBar.svelte → front/src/components/NavBar.svelte

@ -1,9 +1,5 @@
<script lang="ts"> <script lang="ts">
let api = import { API_URL } from "../Auth";
"http://" +
import.meta.env.VITE_HOST +
":" +
import.meta.env.VITE_BACK_PORT;
export let links = [ export let links = [
{ text: "Home" }, { text: "Home" },
@ -54,7 +50,7 @@
{#if link.text === "Profile"} {#if link.text === "Profile"}
<li> <li>
<button on:click={clickProfile}> <button on:click={clickProfile}>
<img src={api + "/users/avatar"} alt="avatar" /> <img src={API_URL + "/users/avatar"} alt="avatar" />
</button> </button>
</li> </li>
{/if} {/if}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save