Add CommunityController

This commit is contained in:
faris Aljohari
2024-03-31 22:29:33 +03:00
parent 4092c67f89
commit 75197664fd
2 changed files with 37 additions and 0 deletions

View File

@ -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,
);
}
}
}

View File

@ -0,0 +1 @@
export * from './community.controller';