diff --git a/src/app.module.ts b/src/app.module.ts index 53a56f466f39eb0e799f5c1c56f9906f9220a102..fea4f14a9d9e13647c838a11972aa368215fb907 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -21,6 +21,19 @@ import { GameModule } from './game/game.module'; import { ScoreModule } from './score/score.module'; import { ReplayModule } from './replay/replay.module'; +/* + Core of the server, + Every module is being imported and combined here. + + TypeOrmModule checks ormconfig.json for database connection. + + Providers can be found from shared folder + - HttpErrorFilter + - LoggingInterceptor + - RolesGuard Decorator + - StatesGuard Decorator +*/ + @Module({ imports: [ TypeOrmModule.forRoot(), diff --git a/src/main.ts b/src/main.ts index ebd53e5906d44738a4775716b7165108fae426ca..2999e140b17ea0d80f29b37be40abf9f37dca1db 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,9 +7,13 @@ import { AppModule } from './app.module'; */ async function bootstrap() { + // port opened + const port = 5000; + const app = await NestFactory.create(AppModule); // Cors is needed for application/json POST app.enableCors(); - await app.listen(5000); + // Server will listen on port + await app.listen(port); } bootstrap(); diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts index 4d4158d3f037850c8c5230975ef5f46ae5a75ede..9afb56d5bf638af1cf6877d1d2b30f1712fda910 100644 --- a/src/user/user.controller.ts +++ b/src/user/user.controller.ts @@ -12,6 +12,15 @@ import { UserDTO } from './user.dto'; import { AuthGuard } from '../shared/auth.guard'; import { ValidationPipe } from '../shared/validation.pipe'; +/* +UserController is being used for routing: +- Login +- Register + +- Verify is checking for logged in user +*/ + + @Controller('user') export class UserController { constructor(private userService: UserService) {} diff --git a/src/user/user.module.ts b/src/user/user.module.ts index 6cb77a7b735df532d710febc33a4df53f264563a..a160e47449b4d3724bfe4350f93569ae8e1073a4 100644 --- a/src/user/user.module.ts +++ b/src/user/user.module.ts @@ -6,8 +6,20 @@ import { UserService } from './user.service'; import { PersonEntity} from './user.entity'; import { GameEntity } from '../game/game.entity'; +/* +Entities +- PersonEntity +- GameEntity + +Controllers +- UserController + +Provider +- UserService +*/ + @Module({ - imports: [TypeOrmModule.forFeature([PersonEntity, GameEntity])], + imports: [TypeOrmModule.forFeature([PersonEntity])], controllers: [UserController], providers: [UserService], }) diff --git a/src/user/user.service.ts b/src/user/user.service.ts index aa511e27802548a17449e7912144598e7eda3732..e405972e9c1faf45d7796831b67266ae7f739870 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -4,16 +4,16 @@ import { InjectRepository } from '@nestjs/typeorm'; import { PersonEntity } from './user.entity'; import { UserDTO } from './user.dto'; -import { GameEntity } from '../game/game.entity'; -import { GameDTO } from '../game/game.dto'; +/* +UserService contains +*/ + @Injectable() export class UserService { constructor( @InjectRepository(PersonEntity) private userRepository: Repository<PersonEntity>, - @InjectRepository(GameEntity) - private gameRepository: Repository<GameEntity>, ) {} async register(data: UserDTO) { @@ -38,25 +38,4 @@ export class UserService { } return user.tokenObject(); } - - // liitytään peliin - async joinGame(game: GameDTO, data: UserDTO) { - try { - // etsi peli valinnan mukaan ja otetaan käyttäjän rooli kyseisestä pelistä talteen - const role = await this.gameRepository.findOne(); - return role; - } catch (error) { - return error.message; - } - } - - // liitytään factionii - async joinFaction(game: GameDTO, data: UserDTO): Promise<boolean> { - try { - // tarkistetaan factionin salasana - return true; - } catch (error) { - return error; - } - } }