feat: Add success response with data in controllers

This commit is contained in:
faris Aljohari
2024-05-19 14:25:19 +03:00
parent 25c3765d9c
commit 835fde8304
6 changed files with 64 additions and 11 deletions

View File

@ -61,7 +61,15 @@ export class DeviceController {
@Post('room')
async addDeviceInRoom(@Body() addDeviceInRoomDto: AddDeviceInRoomDto) {
try {
return await this.deviceService.addDeviceInRoom(addDeviceInRoomDto);
const device =
await this.deviceService.addDeviceInRoom(addDeviceInRoomDto);
return {
statusCode: HttpStatus.CREATED,
success: true,
message: 'device added in room successfully',
data: device,
};
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',