Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/entities/team.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { IsBoolean, IsOptional, IsString } from "class-validator";
name: "teams",
})
export class Team extends Entity {
@ApiProperty()
@ApiProperty({ required: false, description: "Defaults to active hackathon" })
@IsOptional()
@IsString()
@Column({ type: "string" })
@Column({ type: "string", required: false })
hackathonId: string;
@ApiProperty()
@IsString()
Expand Down
10 changes: 9 additions & 1 deletion src/modules/team/team.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { InjectRepository, Repository } from "common/objection";
import { Team, TeamEntity } from "entities/team.entity";
import { User } from "entities/user.entity";
import { Hackathon } from "entities/hackathon.entity";
import { ApiProperty, ApiTags, OmitType, PartialType } from "@nestjs/swagger";
import { Role, Roles } from "common/gcp";
import { ApiDoc } from "common/docs";
Expand Down Expand Up @@ -205,13 +206,20 @@ export class TeamController {
}
}

// Get active hackathon
const hackathon = await Hackathon.query().findOne({ active: true });
if (!hackathon) {
throw new NotFoundException("No active hackathon found");
}

const team = await this.teamRepo
.createOne({
id: nanoid(),
hackathonId: hackathon.id,
isActive: true,
...data,
})
.byHackathon();
.exec();

return team;
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/team/team.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { ObjectionModule } from "common/objection";
import { Team } from "entities/team.entity";
import { User } from "entities/user.entity";
import { TeamController } from "./team.controller";
import { Hackathon } from "entities/hackathon.entity";

@Module({
imports: [ObjectionModule.forFeature([Team, User])],
imports: [ObjectionModule.forFeature([Team, User, Hackathon])],
controllers: [TeamController],
})
export class TeamModule {}