fix api build issues
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { Controller, Get, Post, Patch, Body, Req, Param, Inject } from '@nestjs/common';
|
||||
import { Request } from 'express';
|
||||
import { ApiTags, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
||||
|
||||
type RequestWithUser = Record<string, unknown> & {
|
||||
user?: {
|
||||
userId?: string;
|
||||
};
|
||||
};
|
||||
import { TeamService } from './TeamService';
|
||||
import { GetAllTeamsOutputDTO } from './dtos/GetAllTeamsOutputDTO';
|
||||
import { GetTeamDetailsOutputDTO } from './dtos/GetTeamDetailsOutputDTO';
|
||||
@@ -29,8 +34,8 @@ 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: Request): Promise<GetTeamDetailsOutputDTO | null> {
|
||||
const userId = (req as any)['user']?.userId;
|
||||
async getDetails(@Param('teamId') teamId: string, @Req() req: RequestWithUser): Promise<GetTeamDetailsOutputDTO | null> {
|
||||
const userId = req.user?.userId;
|
||||
return await this.teamService.getDetails(teamId, userId);
|
||||
}
|
||||
|
||||
@@ -51,16 +56,16 @@ export class TeamController {
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new team' })
|
||||
@ApiResponse({ status: 201, description: 'Team created', type: CreateTeamOutputDTO })
|
||||
async create(@Body() input: CreateTeamInputDTO, @Req() req: Request): Promise<CreateTeamOutputDTO> {
|
||||
const userId = (req as any)['user']?.userId;
|
||||
async create(@Body() input: CreateTeamInputDTO, @Req() req: RequestWithUser): Promise<CreateTeamOutputDTO> {
|
||||
const userId = req.user?.userId;
|
||||
return await this.teamService.create(input, userId);
|
||||
}
|
||||
|
||||
@Patch(':teamId')
|
||||
@ApiOperation({ summary: 'Update team' })
|
||||
@ApiResponse({ status: 200, description: 'Team updated', type: UpdateTeamOutputDTO })
|
||||
async update(@Param('teamId') teamId: string, @Body() input: UpdateTeamInput, @Req() req: Request): Promise<UpdateTeamOutputDTO> {
|
||||
const userId = (req as any)['user']?.userId;
|
||||
async update(@Param('teamId') teamId: string, @Body() input: UpdateTeamInput, @Req() req: RequestWithUser): Promise<UpdateTeamOutputDTO> {
|
||||
const userId = req.user?.userId;
|
||||
return await this.teamService.update(teamId, input, userId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user