Add UserRepository and addUserCommunity endpoint

This commit is contained in:
faris Aljohari
2024-04-16 17:22:12 +03:00
parent 1d9bb96a87
commit ae63ac6717
4 changed files with 63 additions and 3 deletions

View File

@ -13,9 +13,13 @@ import {
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
import { AddCommunityDto } from '../dtos/add.community.dto';
import {
AddCommunityDto,
AddUserCommunityDto,
} from '../dtos/add.community.dto';
import { GetCommunityChildDto } from '../dtos/get.community.dto';
import { UpdateCommunityNameDto } from '../dtos/update.community.dto';
import { CheckUserCommunityGuard } from 'src/guards/user.community.guard';
@ApiTags('Community Module')
@Controller({
@ -90,7 +94,20 @@ export class CommunityController {
);
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard, CheckUserCommunityGuard)
@Post('user')
async addUserCommunity(@Body() addUserCommunityDto: AddUserCommunityDto) {
try {
await this.communityService.addUserCommunity(addUserCommunityDto);
return { message: 'user community added successfully' };
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Put('rename/:communityUuid')