Skip to content
Snippets Groups Projects
Commit 74e4d57a authored by L4072's avatar L4072
Browse files

auditing backend

parent 1c40062e
No related branches found
No related tags found
2 merge requests!59Development to master,!58Development to testing
...@@ -21,6 +21,19 @@ import { GameModule } from './game/game.module'; ...@@ -21,6 +21,19 @@ import { GameModule } from './game/game.module';
import { ScoreModule } from './score/score.module'; import { ScoreModule } from './score/score.module';
import { ReplayModule } from './replay/replay.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({ @Module({
imports: [ imports: [
TypeOrmModule.forRoot(), TypeOrmModule.forRoot(),
......
...@@ -7,9 +7,13 @@ import { AppModule } from './app.module'; ...@@ -7,9 +7,13 @@ import { AppModule } from './app.module';
*/ */
async function bootstrap() { async function bootstrap() {
// port opened
const port = 5000;
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
// Cors is needed for application/json POST // Cors is needed for application/json POST
app.enableCors(); app.enableCors();
await app.listen(5000); // Server will listen on port
await app.listen(port);
} }
bootstrap(); bootstrap();
...@@ -12,6 +12,15 @@ import { UserDTO } from './user.dto'; ...@@ -12,6 +12,15 @@ import { UserDTO } from './user.dto';
import { AuthGuard } from '../shared/auth.guard'; import { AuthGuard } from '../shared/auth.guard';
import { ValidationPipe } from '../shared/validation.pipe'; import { ValidationPipe } from '../shared/validation.pipe';
/*
UserController is being used for routing:
- Login
- Register
- Verify is checking for logged in user
*/
@Controller('user') @Controller('user')
export class UserController { export class UserController {
constructor(private userService: UserService) {} constructor(private userService: UserService) {}
......
...@@ -6,8 +6,20 @@ import { UserService } from './user.service'; ...@@ -6,8 +6,20 @@ import { UserService } from './user.service';
import { PersonEntity} from './user.entity'; import { PersonEntity} from './user.entity';
import { GameEntity } from '../game/game.entity'; import { GameEntity } from '../game/game.entity';
/*
Entities
- PersonEntity
- GameEntity
Controllers
- UserController
Provider
- UserService
*/
@Module({ @Module({
imports: [TypeOrmModule.forFeature([PersonEntity, GameEntity])], imports: [TypeOrmModule.forFeature([PersonEntity])],
controllers: [UserController], controllers: [UserController],
providers: [UserService], providers: [UserService],
}) })
......
...@@ -4,16 +4,16 @@ import { InjectRepository } from '@nestjs/typeorm'; ...@@ -4,16 +4,16 @@ import { InjectRepository } from '@nestjs/typeorm';
import { PersonEntity } from './user.entity'; import { PersonEntity } from './user.entity';
import { UserDTO } from './user.dto'; import { UserDTO } from './user.dto';
import { GameEntity } from '../game/game.entity'; /*
import { GameDTO } from '../game/game.dto'; UserService contains
*/
@Injectable() @Injectable()
export class UserService { export class UserService {
constructor( constructor(
@InjectRepository(PersonEntity) @InjectRepository(PersonEntity)
private userRepository: Repository<PersonEntity>, private userRepository: Repository<PersonEntity>,
@InjectRepository(GameEntity)
private gameRepository: Repository<GameEntity>,
) {} ) {}
async register(data: UserDTO) { async register(data: UserDTO) {
...@@ -38,25 +38,4 @@ export class UserService { ...@@ -38,25 +38,4 @@ export class UserService {
} }
return user.tokenObject(); 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;
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment