forked from Cutlery/immich
- Refactor user business logic from `user.service` into `user.domain` Make user business logic reusable by using `user.domain` from other services than `user.service` - Add `jest-when` lib to make testing easier and use it in `userService` Using when helps from coupling tests to order of mock implementations execution - Move all user business logic from user-repository to user.service - Fix user.service tests not awaiting promises leaking state between tests - Presentation logic for `getUserProfileImage` moved from UserService to UserController - Fix `user.e2e` test logic. Pending fixing the configuration of the test itself
54 lines
1002 B
TypeScript
54 lines
1002 B
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { Transform } from 'class-transformer';
|
|
import { IsNotEmpty, IsEmail } from 'class-validator';
|
|
|
|
export class CreateUserDto {
|
|
@IsEmail()
|
|
@Transform(({ value }) => value?.toLowerCase())
|
|
@ApiProperty({ example: 'testuser@email.com' })
|
|
email!: string;
|
|
|
|
@IsNotEmpty()
|
|
@ApiProperty({ example: 'password' })
|
|
password!: string;
|
|
|
|
@IsNotEmpty()
|
|
@ApiProperty({ example: 'John' })
|
|
firstName!: string;
|
|
|
|
@IsNotEmpty()
|
|
@ApiProperty({ example: 'Doe' })
|
|
lastName!: string;
|
|
}
|
|
|
|
export class CreateAdminDto {
|
|
@IsNotEmpty()
|
|
isAdmin!: true;
|
|
|
|
@IsEmail()
|
|
@Transform(({ value }) => value?.toLowerCase())
|
|
email!: string;
|
|
|
|
@IsNotEmpty()
|
|
password!: string;
|
|
|
|
@IsNotEmpty()
|
|
firstName!: string;
|
|
|
|
@IsNotEmpty()
|
|
lastName!: string;
|
|
}
|
|
|
|
export class CreateUserOAuthDto {
|
|
@IsEmail()
|
|
@Transform(({ value }) => value?.toLowerCase())
|
|
email!: string;
|
|
|
|
@IsNotEmpty()
|
|
oauthId!: string;
|
|
|
|
firstName?: string;
|
|
|
|
lastName?: string;
|
|
}
|