fix validation

This commit is contained in:
Gsk54 2022-12-23 15:29:53 +01:00
parent 5e4b777ab8
commit a34d51a524
5 changed files with 18 additions and 8 deletions

2
.env
View File

@ -7,8 +7,6 @@ SERVICE_PORT=5002
DATABASE_URL="postgresql://auth:auth@v3-auth-db:5432/auth?schema=public"
# RABBIT MQ
RMQ_EXCHANGE_NAME=user
RMQ_EXCHANGE_TYPE=topic
RMQ_URI=amqp://v3-gateway-broker:5672
# POSTGRES

View File

@ -7,8 +7,6 @@ SERVICE_PORT=5002
DATABASE_URL="postgresql://auth:auth@db:5432/auth?schema=public"
# RABBIT MQ
RMQ_EXCHANGES=user
RMQ_EXCHANGE_TYPE=topic
RMQ_URI=amqp://localhost:5672
# POSTGRES

View File

@ -13,7 +13,7 @@ export class AuthMessagerController {
@RabbitSubscribe({
exchange: 'user',
routingKey: 'user.update',
routingKey: 'update',
queue: 'auth-user-update',
})
public async userUpdatedHandler(message: string) {
@ -41,7 +41,7 @@ export class AuthMessagerController {
@RabbitSubscribe({
exchange: 'user',
routingKey: 'user.delete',
routingKey: 'delete',
queue: 'auth-user-delete',
})
public async userDeletedHandler(message: string) {

View File

@ -0,0 +1,14 @@
import { Injectable, ValidationPipe } from '@nestjs/common';
import { RpcException } from '@nestjs/microservices';
@Injectable()
export class RpcValidationPipe extends ValidationPipe {
createExceptionFactory() {
return (validationErrors = []) => {
return new RpcException({
code: 3,
message: this.flattenValidationErrors(validationErrors),
});
};
}
}

View File

@ -25,8 +25,8 @@ import { AuthMessagerController } from './adapters/primaries/auth-messager.contr
useFactory: async (configService: ConfigService) => ({
exchanges: [
{
name: configService.get<string>('RMQ_EXCHANGE_NAME'),
type: configService.get<string>('RMQ_EXCHANGE_TYPE'),
name: 'user',
type: 'topic',
},
],
uri: configService.get<string>('RMQ_URI'),