1
0
forked from Cutlery/immich
Jaime Baez 20c5578470
Make user business logic reusable (#1114)
- 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
2022-12-23 21:08:50 +01:00

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;
}