mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-08-26 03:29:41 +00:00
Add get Communities endpoint
This commit is contained in:
@ -10,6 +10,7 @@ import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { AddCommunityDto, AddUserCommunityDto } from '../dtos';
|
||||
import {
|
||||
CommunityChildInterface,
|
||||
GetCommunitiesInterface,
|
||||
GetCommunityByUserUuidInterface,
|
||||
GetCommunityByUuidInterface,
|
||||
RenameCommunityByUuidInterface,
|
||||
@ -79,6 +80,23 @@ export class CommunityService {
|
||||
}
|
||||
}
|
||||
}
|
||||
async getCommunities(): Promise<GetCommunitiesInterface> {
|
||||
try {
|
||||
const community = await this.spaceRepository.find({
|
||||
where: { spaceType: { type: 'community' } },
|
||||
relations: ['spaceType'],
|
||||
});
|
||||
return community.map((community) => ({
|
||||
uuid: community.uuid,
|
||||
createdAt: community.createdAt,
|
||||
updatedAt: community.updatedAt,
|
||||
name: community.spaceName,
|
||||
type: community.spaceType.type,
|
||||
}));
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
async getCommunityChildByUuid(
|
||||
communityUuid: string,
|
||||
getCommunityChildDto: GetCommunityChildDto,
|
||||
|
Reference in New Issue
Block a user