Skip to content

Commit

Permalink
finish game create flow
Browse files Browse the repository at this point in the history
  • Loading branch information
melihgezerr committed Oct 30, 2023
1 parent 054bb34 commit c732149
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
13 changes: 11 additions & 2 deletions ludos/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { UserController } from './controllers/user.controller';
import { UserService } from './services/user.service';
import { JwtModule } from '@nestjs/jwt';
import { JwtConfigService } from './services/config/jwt-config.service';
import { GameController } from './controllers/game.controller';
import { GameService } from './services/game.service';
import { GameRepository } from './repositories/game.repository';

@Module({
imports: [
Expand All @@ -26,7 +29,13 @@ import { JwtConfigService } from './services/config/jwt-config.service';
}),
TypeOrmModule.forFeature([User]),
],
controllers: [AppController, UserController],
providers: [AppService, UserRepository, UserService],
controllers: [AppController, UserController, GameController],
providers: [
AppService,
UserRepository,
UserService,
GameRepository,
GameService,
],
})
export class AppModule {}
24 changes: 12 additions & 12 deletions ludos/backend/src/entities/game.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
@Entity('games')
export class Game {
@PrimaryGeneratedColumn('uuid')
id: string;
Expand All @@ -11,13 +11,13 @@ export class Game {
@Column({ type: 'text' })
coverLink: string;

@Column('float')
@Column({ type: 'float', default: 0 })
averageRating: number;

@Column('float')
@Column({ type: 'float', default: 0 })
userRating: number;

@Column('int')
@Column({ type: 'int', default: 0 })
followers: number;

@Column('jsonb')
Expand All @@ -31,10 +31,10 @@ export class Game {
};
};

@Column('float')
@Column({ type: 'float', default: 0 })
userCompilationDuration: number;

@Column('float')
@Column({ type: 'float', default: 0 })
averageUserCompilationDuration: number;

@Column('text', { array: true })
Expand All @@ -55,22 +55,22 @@ export class Game {
@Column({ type: 'varchar', length: 50 })
ageRestriction: string;

@Column('text', { array: true })
@Column('text', { array: true, default: '{}' })
characters: string[];

@Column('text', { array: true })
@Column('text', { array: true, default: '{}' })
areas: string[];

@Column('text', { array: true })
@Column('text', { array: true, default: '{}' })
packages: string[];

@Column('text', { array: true })
@Column('text', { array: true, default: '{}' })
items: string[];

@Column('text')
gameBio: string;

@Column('text', { array: true })
@Column('text', { array: true, default: '{}' })
groups: string[];

@Column('text', { array: true })
Expand All @@ -88,6 +88,6 @@ export class Game {
@Column('text')
trivia: string;

@Column('text', { array: true })
@Column('text', { array: true, default: '{}' })
reviews: string[];
}
3 changes: 2 additions & 1 deletion ludos/backend/src/services/config/typeorm-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm';
import { User } from '../../entities/user.entity';
import { Game } from '../../entities/game.entity';

@Injectable()
export class TypeOrmConfigService implements TypeOrmOptionsFactory {
Expand All @@ -15,7 +16,7 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory {
password: this.configService.get<string>('DB_PASSWORD'),
port: this.configService.get<number>('DB_PORT'),
database: this.configService.get<string>('DB_NAME'),
entities: [User],
entities: [User, Game],
synchronize: true,
};
}
Expand Down

0 comments on commit c732149

Please sign in to comment.