send logging messages

This commit is contained in:
Gsk54
2022-12-23 15:14:51 +01:00
parent 4e2ee28219
commit 6eb9b40e14
17 changed files with 151 additions and 66 deletions

View File

@@ -1,11 +1,6 @@
import { Mapper } from '@automapper/core';
import { InjectMapper } from '@automapper/nestjs';
import {
Controller,
UsePipes,
ValidationError,
ValidationPipe,
} from '@nestjs/common';
import { Controller, UsePipes } from '@nestjs/common';
import { CommandBus, QueryBus } from '@nestjs/cqrs';
import { GrpcMethod, RpcException } from '@nestjs/microservices';
import { DatabaseException } from 'src/modules/database/src/exceptions/DatabaseException';
@@ -46,16 +41,17 @@ export class UsersController {
@GrpcMethod('UsersService', 'FindOneByUuid')
async findOneByUuid(data: FindUserByUuidRequest): Promise<UserPresenter> {
const user = await this._queryBus.execute(
new FindUserByUuidQuery(data.uuid),
);
if (user) {
try {
const user = await this._queryBus.execute(
new FindUserByUuidQuery(data.uuid),
);
return this._mapper.map(user, User, UserPresenter);
} catch (error) {
throw new RpcException({
code: 5,
message: 'User not found',
});
}
throw new RpcException({
code: 5,
message: 'User not found',
});
}
@GrpcMethod('UsersService', 'Create')