refactor
This commit is contained in:
		
							parent
							
								
									6802cd3620
								
							
						
					
					
						commit
						d5be05585d
					
				| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
package user1
 | 
					package user.me
 | 
				
			||||||
 | 
					
 | 
				
			||||||
default allow := false
 | 
					default allow := false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
package user2
 | 
					package user.list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
default allow := false
 | 
					default allow := false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ export class AuthenticationMessagerController {
 | 
				
			||||||
  @RabbitSubscribe({
 | 
					  @RabbitSubscribe({
 | 
				
			||||||
    exchange: 'user',
 | 
					    exchange: 'user',
 | 
				
			||||||
    routingKey: 'update',
 | 
					    routingKey: 'update',
 | 
				
			||||||
    queue: 'auth-user-update',
 | 
					    queue: 'authentication-user-update',
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
  public async userUpdatedHandler(message: string) {
 | 
					  public async userUpdatedHandler(message: string) {
 | 
				
			||||||
    const updatedUser = JSON.parse(message);
 | 
					    const updatedUser = JSON.parse(message);
 | 
				
			||||||
| 
						 | 
					@ -42,15 +42,15 @@ export class AuthenticationMessagerController {
 | 
				
			||||||
  @RabbitSubscribe({
 | 
					  @RabbitSubscribe({
 | 
				
			||||||
    exchange: 'user',
 | 
					    exchange: 'user',
 | 
				
			||||||
    routingKey: 'delete',
 | 
					    routingKey: 'delete',
 | 
				
			||||||
    queue: 'auth-user-delete',
 | 
					    queue: 'authentication-user-delete',
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
  public async userDeletedHandler(message: string) {
 | 
					  public async userDeletedHandler(message: string) {
 | 
				
			||||||
    const deletedUser = JSON.parse(message);
 | 
					    const deletedUser = JSON.parse(message);
 | 
				
			||||||
    if (!deletedUser.hasOwnProperty('uuid')) throw new Error();
 | 
					    if (!deletedUser.hasOwnProperty('uuid')) throw new Error();
 | 
				
			||||||
    const deleteAuthRequest = new DeleteAuthenticationRequest();
 | 
					    const deleteAuthenticationRequest = new DeleteAuthenticationRequest();
 | 
				
			||||||
    deleteAuthRequest.uuid = deletedUser.uuid;
 | 
					    deleteAuthenticationRequest.uuid = deletedUser.uuid;
 | 
				
			||||||
    await this._commandBus.execute(
 | 
					    await this._commandBus.execute(
 | 
				
			||||||
      new DeleteAuthenticationCommand(deleteAuthRequest),
 | 
					      new DeleteAuthenticationCommand(deleteAuthenticationRequest),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,7 @@ import { DeleteAuthenticationRequest } from '../../domain/dtos/delete-authentica
 | 
				
			||||||
import { DeleteUsernameRequest } from '../../domain/dtos/delete-username.request';
 | 
					import { DeleteUsernameRequest } from '../../domain/dtos/delete-username.request';
 | 
				
			||||||
import { UpdatePasswordRequest } from '../../domain/dtos/update-password.request';
 | 
					import { UpdatePasswordRequest } from '../../domain/dtos/update-password.request';
 | 
				
			||||||
import { UpdateUsernameRequest } from '../../domain/dtos/update-username.request';
 | 
					import { UpdateUsernameRequest } from '../../domain/dtos/update-username.request';
 | 
				
			||||||
import { ValidateAuthRequest } from '../../domain/dtos/validate-authentication.request';
 | 
					import { ValidateAuthenticationRequest } from '../../domain/dtos/validate-authentication.request';
 | 
				
			||||||
import { Authentication } from '../../domain/entities/authentication';
 | 
					import { Authentication } from '../../domain/entities/authentication';
 | 
				
			||||||
import { Username } from '../../domain/entities/username';
 | 
					import { Username } from '../../domain/entities/username';
 | 
				
			||||||
import { ValidateAuthenticationQuery } from '../../queries/validate-authentication.query';
 | 
					import { ValidateAuthenticationQuery } from '../../queries/validate-authentication.query';
 | 
				
			||||||
| 
						 | 
					@ -38,8 +38,10 @@ export class AuthenticationController {
 | 
				
			||||||
    @InjectMapper() private readonly _mapper: Mapper,
 | 
					    @InjectMapper() private readonly _mapper: Mapper,
 | 
				
			||||||
  ) {}
 | 
					  ) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @GrpcMethod('AuthService', 'Validate')
 | 
					  @GrpcMethod('AuthenticationService', 'Validate')
 | 
				
			||||||
  async validate(data: ValidateAuthRequest): Promise<AuthenticationPresenter> {
 | 
					  async validate(
 | 
				
			||||||
 | 
					    data: ValidateAuthenticationRequest,
 | 
				
			||||||
 | 
					  ): Promise<AuthenticationPresenter> {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      const auth: Authentication = await this._queryBus.execute(
 | 
					      const auth: Authentication = await this._queryBus.execute(
 | 
				
			||||||
        new ValidateAuthenticationQuery(data.username, data.password),
 | 
					        new ValidateAuthenticationQuery(data.username, data.password),
 | 
				
			||||||
| 
						 | 
					@ -53,7 +55,7 @@ export class AuthenticationController {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @GrpcMethod('AuthService', 'Create')
 | 
					  @GrpcMethod('AuthenticationService', 'Create')
 | 
				
			||||||
  async createUser(
 | 
					  async createUser(
 | 
				
			||||||
    data: CreateAuthenticationRequest,
 | 
					    data: CreateAuthenticationRequest,
 | 
				
			||||||
  ): Promise<AuthenticationPresenter> {
 | 
					  ): Promise<AuthenticationPresenter> {
 | 
				
			||||||
| 
						 | 
					@ -78,7 +80,7 @@ export class AuthenticationController {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @GrpcMethod('AuthService', 'AddUsername')
 | 
					  @GrpcMethod('AuthenticationService', 'AddUsername')
 | 
				
			||||||
  async addUsername(data: AddUsernameRequest): Promise<UsernamePresenter> {
 | 
					  async addUsername(data: AddUsernameRequest): Promise<UsernamePresenter> {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      const username: Username = await this._commandBus.execute(
 | 
					      const username: Username = await this._commandBus.execute(
 | 
				
			||||||
| 
						 | 
					@ -102,7 +104,7 @@ export class AuthenticationController {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @GrpcMethod('AuthService', 'UpdateUsername')
 | 
					  @GrpcMethod('AuthenticationService', 'UpdateUsername')
 | 
				
			||||||
  async updateUsername(
 | 
					  async updateUsername(
 | 
				
			||||||
    data: UpdateUsernameRequest,
 | 
					    data: UpdateUsernameRequest,
 | 
				
			||||||
  ): Promise<UsernamePresenter> {
 | 
					  ): Promise<UsernamePresenter> {
 | 
				
			||||||
| 
						 | 
					@ -128,7 +130,7 @@ export class AuthenticationController {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @GrpcMethod('AuthService', 'UpdatePassword')
 | 
					  @GrpcMethod('AuthenticationService', 'UpdatePassword')
 | 
				
			||||||
  async updatePassword(
 | 
					  async updatePassword(
 | 
				
			||||||
    data: UpdatePasswordRequest,
 | 
					    data: UpdatePasswordRequest,
 | 
				
			||||||
  ): Promise<AuthenticationPresenter> {
 | 
					  ): Promise<AuthenticationPresenter> {
 | 
				
			||||||
| 
						 | 
					@ -146,7 +148,7 @@ export class AuthenticationController {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @GrpcMethod('AuthService', 'DeleteUsername')
 | 
					  @GrpcMethod('AuthenticationService', 'DeleteUsername')
 | 
				
			||||||
  async deleteUsername(data: DeleteUsernameRequest) {
 | 
					  async deleteUsername(data: DeleteUsernameRequest) {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      return await this._commandBus.execute(new DeleteUsernameCommand(data));
 | 
					      return await this._commandBus.execute(new DeleteUsernameCommand(data));
 | 
				
			||||||
| 
						 | 
					@ -158,8 +160,8 @@ export class AuthenticationController {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @GrpcMethod('AuthService', 'Delete')
 | 
					  @GrpcMethod('AuthenticationService', 'Delete')
 | 
				
			||||||
  async deleteAuth(data: DeleteAuthenticationRequest) {
 | 
					  async deleteAuthentication(data: DeleteAuthenticationRequest) {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      return await this._commandBus.execute(
 | 
					      return await this._commandBus.execute(
 | 
				
			||||||
        new DeleteAuthenticationCommand(data),
 | 
					        new DeleteAuthenticationCommand(data),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue