From 75197664fdca418014de00452611d27db3df06c1 Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Sun, 31 Mar 2024 22:29:33 +0300 Subject: [PATCH] Add CommunityController --- .../controllers/community.controller.ts | 36 +++++++++++++++++++ src/community/controllers/index.ts | 1 + 2 files changed, 37 insertions(+) create mode 100644 src/community/controllers/community.controller.ts create mode 100644 src/community/controllers/index.ts diff --git a/src/community/controllers/community.controller.ts b/src/community/controllers/community.controller.ts new file mode 100644 index 0000000..3fb10cd --- /dev/null +++ b/src/community/controllers/community.controller.ts @@ -0,0 +1,36 @@ +import { CommunityService } from '../services/community.service'; +import { + Body, + Controller, + HttpException, + HttpStatus, + Post, + UseGuards, +} 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'; + +@ApiTags('Community Module') +@Controller({ + version: '1', + path: 'community', +}) +export class CommunityController { + constructor(private readonly communityService: CommunityService) {} + + @ApiBearerAuth() + @UseGuards(JwtAuthGuard) + @Post() + async addCommunity(@Body() addCommunityDto: AddCommunityDto) { + try { + await this.communityService.addCommunity(addCommunityDto); + return { message: 'Community added successfully' }; + } catch (error) { + throw new HttpException( + error.message || 'Internal server error', + HttpStatus.INTERNAL_SERVER_ERROR, + ); + } + } +} diff --git a/src/community/controllers/index.ts b/src/community/controllers/index.ts new file mode 100644 index 0000000..b78bbea --- /dev/null +++ b/src/community/controllers/index.ts @@ -0,0 +1 @@ +export * from './community.controller';