mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 20:14:53 +00:00
Add CommunityController
This commit is contained in:
36
src/community/controllers/community.controller.ts
Normal file
36
src/community/controllers/community.controller.ts
Normal 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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/community/controllers/index.ts
Normal file
1
src/community/controllers/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './community.controller';
|
||||||
Reference in New Issue
Block a user