File tree Expand file tree Collapse file tree 5 files changed +20
-10
lines changed Expand file tree Collapse file tree 5 files changed +20
-10
lines changed Original file line number Diff line number Diff line change 1
1
import { Account } from '@modules/authentication/domain/entities/Account'
2
2
import { LoginResultDto } from '@modules/authentication/presentation/dtos/LoginDto'
3
3
import { AccountDto } from '@modules/shared/presentation/dto/AccountDto'
4
+ import { GetAccountResponseDto } from '@modules/users/presentation/dto/getAccountResponseDto'
4
5
import { BadRequestException , Injectable } from '@nestjs/common'
5
6
import * as crypto from 'node:crypto'
6
7
import { IAuthenticationClient } from '../../modules/shared/infrastructure/IAuthenticationClient'
@@ -55,7 +56,7 @@ export class AuthenticationClient implements IAuthenticationClient {
55
56
return false
56
57
}
57
58
58
- async getAllAccounts ( ) : Promise < AccountDto [ ] > {
59
+ async getAllAccounts ( ) : Promise < GetAccountResponseDto [ ] > {
59
60
accounts . map ( ( account ) => {
60
61
delete account . password
61
62
return account
@@ -67,11 +68,12 @@ export class AuthenticationClient implements IAuthenticationClient {
67
68
return accounts . find ( ( account ) => account . email === email )
68
69
}
69
70
70
- async getAccountById ( id : string ) : Promise < AccountDto > {
71
+ async getAccountById ( id : string ) : Promise < GetAccountResponseDto > {
71
72
const accountExists = accounts . find ( ( account ) => account . id === id )
72
73
if ( ! accountExists ) {
73
74
throw new BadRequestException ( ClientErrorMessages . ACCOUNT_NOT_FOUND )
74
75
}
76
+ delete accountExists . password
75
77
return accountExists
76
78
}
77
79
Original file line number Diff line number Diff line change 1
1
import { LoginResultDto } from '@modules/authentication/presentation/dtos/LoginDto'
2
2
import { AccountDto } from '@modules/shared/presentation/dto/AccountDto'
3
+ import { GetAccountResponseDto } from '@modules/users/presentation/dto/getAccountResponseDto'
3
4
4
5
export interface ClientResult < T > {
5
6
status : number
@@ -10,8 +11,8 @@ export interface IAuthenticationClient {
10
11
createAccount ( account : AccountDto ) : Promise < AccountDto >
11
12
login ( email : string , password : string ) : Promise < LoginResultDto >
12
13
validateLogin ( loginToken : string ) : Promise < boolean >
13
- getAllAccounts ( ) : Promise < AccountDto [ ] >
14
+ getAllAccounts ( ) : Promise < GetAccountResponseDto [ ] >
14
15
getAccountByEmail ( email : string ) : Promise < AccountDto >
15
- getAccountById ( id : string ) : Promise < AccountDto >
16
+ getAccountById ( id : string ) : Promise < GetAccountResponseDto >
16
17
deleteAccountByEmail ( email : string ) : Promise < boolean >
17
18
}
Original file line number Diff line number Diff line change 1
- import { AccountDto } from '@modules/shared/ presentation/dto/AccountDto '
1
+ import { GetAccountResponseDto } from '../ presentation/dto/getAccountResponseDto '
2
2
3
3
export interface IUsersService {
4
- listAllUsers ( ) : Promise < AccountDto [ ] >
5
- getUserById ( id : string ) : Promise < AccountDto >
4
+ listAllUsers ( ) : Promise < GetAccountResponseDto [ ] >
5
+ getUserById ( id : string ) : Promise < GetAccountResponseDto >
6
6
}
Original file line number Diff line number Diff line change 1
1
import { InfrastructureInjectionList } from '@infrastructure/InfrastructureInjectionList'
2
- import { AccountDto } from '@modules/shared/presentation/dto/AccountDto'
3
2
import { Inject , Injectable } from '@nestjs/common'
4
3
import { IAuthenticationClient } from '../../shared/infrastructure/IAuthenticationClient'
4
+ import { GetAccountResponseDto } from '../presentation/dto/getAccountResponseDto'
5
5
import { IUsersService } from './IUsersService'
6
6
7
7
@Injectable ( )
@@ -11,11 +11,11 @@ export class UsersService implements IUsersService {
11
11
private readonly authenticationClient : IAuthenticationClient
12
12
) { }
13
13
14
- async listAllUsers ( ) : Promise < AccountDto [ ] > {
14
+ async listAllUsers ( ) : Promise < GetAccountResponseDto [ ] > {
15
15
return await this . authenticationClient . getAllAccounts ( )
16
16
}
17
17
18
- async getUserById ( id : string ) : Promise < AccountDto > {
18
+ async getUserById ( id : string ) : Promise < GetAccountResponseDto > {
19
19
return await this . authenticationClient . getAccountById ( id )
20
20
}
21
21
Original file line number Diff line number Diff line change
1
+
2
+ export type GetAccountResponseDto = {
3
+ id : string
4
+ name : string
5
+ email : string
6
+ zipCode : string
7
+ }
You can’t perform that action at this time.
0 commit comments