fix(mobile): omit null values from json requests (#1212)

* chore: initial template

* feat: exlude null values

* chore: regenerate openapi

* chore: merge

* feat: store changes in a patch file

* feat: extract to sh script

* chore: regenerate openapi

* chore: remove duplicate file

* feat: generate mobile by itself

* Fixed number property not decorated correctly

* Revert hotfix, fix test

* Merge main

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Jason Rasmussen
2023-01-09 23:08:45 -05:00
committed by GitHub
parent bd838a71d1
commit 079ee658a5
79 changed files with 890 additions and 557 deletions

View File

@@ -1,6 +1,8 @@
import { APIKeyEntity } from '@app/database';
import { ApiProperty } from '@nestjs/swagger';
export class APIKeyResponseDto {
@ApiProperty({ type: 'integer' })
id!: number;
name!: string;
createdAt!: string;

View File

@@ -35,25 +35,12 @@ export class UserCore {
}
}
const user = await this.userRepository.get(id);
if (!user) {
throw new NotFoundException('User not found');
}
try {
if (dto.password) {
dto.password = await hash(dto.password, SALT_ROUNDS);
}
user.password = dto.password ?? user.password;
user.email = dto.email ?? user.email;
user.firstName = dto.firstName ?? user.firstName;
user.lastName = dto.lastName ?? user.lastName;
user.isAdmin = dto.isAdmin ?? user.isAdmin;
user.shouldChangePassword = dto.shouldChangePassword ?? user.shouldChangePassword;
user.profileImagePath = dto.profileImagePath ?? user.profileImagePath;
return this.userRepository.update(id, user);
return this.userRepository.update(id, dto);
} catch (e) {
Logger.error(e, 'Failed to update user info');
throw new InternalServerErrorException('Failed to update user info');