Add Default Door Lock Password and Open Door Lock Endpoint

This commit is contained in:
faris Aljohari
2024-08-12 11:46:24 +03:00
parent 34663dec77
commit d40af71e78
3 changed files with 73 additions and 0 deletions

View File

@ -211,4 +211,23 @@ export class DoorLockController {
);
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Post('open/:doorLockUuid')
async openDoorLock(@Param('doorLockUuid') doorLockUuid: string) {
try {
await this.doorLockService.openDoorLock(doorLockUuid);
return {
statusCode: HttpStatus.CREATED,
success: true,
message: 'door lock opened successfully',
};
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
}