Refactor controllers to return UUID of added entities

This commit is contained in:
faris Aljohari
2024-05-01 10:34:07 +03:00
parent 229909f959
commit d146cce1bb
10 changed files with 21 additions and 15 deletions
@@ -34,8 +34,9 @@ export class CommunityController {
@Post()
async addCommunity(@Body() addCommunityDto: AddCommunityDto) {
try {
await this.communityService.addCommunity(addCommunityDto);
return { message: 'Community added successfully' };
const community =
await this.communityService.addCommunity(addCommunityDto);
return { message: 'Community added successfully', uuid: community.uuid };
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
+2 -1
View File
@@ -34,10 +34,11 @@ export class CommunityService {
},
});
await this.spaceRepository.save({
const community = await this.spaceRepository.save({
spaceName: addCommunityDto.communityName,
spaceType: { uuid: spaceType.uuid },
});
return community;
} catch (err) {
throw new HttpException(err.message, HttpStatus.INTERNAL_SERVER_ERROR);
}