tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Controller, Get, Post, Patch, Body, Req, Param, Inject } from '@nestjs/common';
|
||||
import { Controller, Get, Post, Patch, Body, Req, Param, Inject, NotFoundException } from '@nestjs/common';
|
||||
import { ApiTags, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
||||
import { Public } from '../auth/Public';
|
||||
|
||||
@@ -37,9 +37,13 @@ export class TeamController {
|
||||
@ApiOperation({ summary: 'Get team details' })
|
||||
@ApiResponse({ status: 200, description: 'Team details', type: GetTeamDetailsOutputDTO })
|
||||
@ApiResponse({ status: 404, description: 'Team not found' })
|
||||
async getDetails(@Param('teamId') teamId: string, @Req() req: RequestWithUser): Promise<GetTeamDetailsOutputDTO | null> {
|
||||
async getDetails(@Param('teamId') teamId: string, @Req() req: RequestWithUser): Promise<GetTeamDetailsOutputDTO> {
|
||||
const userId = req.user?.userId;
|
||||
return await this.teamService.getDetails(teamId, userId);
|
||||
const result = await this.teamService.getDetails(teamId, userId);
|
||||
if (!result) {
|
||||
throw new NotFoundException('Team not found');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Public()
|
||||
@@ -90,4 +94,15 @@ export class TeamController {
|
||||
async getMembership(@Param('teamId') teamId: string, @Param('driverId') driverId: string): Promise<GetTeamMembershipOutputDTO | null> {
|
||||
return await this.teamService.getMembership(teamId, driverId);
|
||||
}
|
||||
}
|
||||
|
||||
@Post(':teamId/join')
|
||||
@ApiOperation({ summary: 'Join a team (actor derived from session)' })
|
||||
@ApiResponse({ status: 200, description: 'Joined team successfully' })
|
||||
async joinTeam(
|
||||
@Param('teamId') teamId: string,
|
||||
@Req() req: RequestWithUser,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const userId = req.user?.userId;
|
||||
return await this.teamService.joinTeam(teamId, userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user