This commit is contained in:
dahyeon committed 2026-04-24 23:18:56 -07:00
1 parent 30dfb7ce58
commit 5af2c80cd1
33 files changed
+3806 -1440

No files matched your search

@@ -2,6 +2,7 @@ import {
Body,
Controller,
ForbiddenException,
Get,
Param,
Patch,
Post,
@@ -26,6 +27,14 @@ export class CommunityController {
return this.communityService.createCommunityWithOwner(body);
}
@Get(':communityId')
public async getCommunity(
@Param('communityId', ParseObjectIdPipe)
communityId: mongoose.Types.ObjectId,
) {
return this.communityService.getById(communityId);
}
@Patch(':communityId/members/:userId/promote')
@Roles('owner')
@UseGuards(RolesGuard)
@@ -26,6 +26,15 @@ export interface CreateCommunityInput {
export class CommunityService {
constructor(private readonly connectionService: ConnectionService) {}
public async getById(
communityId: mongoose.Types.ObjectId,
): Promise<CommunityDocument> {
const CommunityModel = await this.connectionService.getModel('community');
const community = await CommunityModel.findById(communityId).exec();
if (!community) throw new NotFoundException('Community not found.');
return community;
}
public async createCommunityWithOwner(input: CreateCommunityInput): Promise<{
community: CommunityDocument;
owner: UserDocument;