Skip to content

Commit

Permalink
[imp]: audith on findUser (/user)
Browse files Browse the repository at this point in the history
  • Loading branch information
argotte committed Jan 15, 2024
1 parent 093facc commit 49a45f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class FindUserById implements IApplicationService<string, User> {
private readonly transactionHandler: ItransactionHandler
) {}
get name(): string {
throw new Error("Method not implemented.");
return this.constructor.name;
}

async execute(id: string): Promise<Result<User>>{
Expand Down
13 changes: 11 additions & 2 deletions src/users/infrastructure/controllers/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class UsersController {
@ApiTags('Users')
@Post('/auth/log-in')
async signin(@Body() body: CreateUserDto) {

const service = new AudithApplicationServiceDecorator(
new LoggingApplicationServiceDecorator(
new SignUserIn(this.findByPhoneUserService),
Expand Down Expand Up @@ -281,7 +281,16 @@ export class UsersController {
async findUser(@Req() req: Request, @Headers() headers: Headers) {
const token = req.headers['authorization']?.split(' ')[1] ?? '';
const id = await this.jwtService.decode(token).id;
const user = await this.findUserById.execute(id);
const service = new AudithApplicationServiceDecorator(
new LoggingApplicationServiceDecorator(
new FindUserById(this.userRepository, this.transactionHandler),
new NestLogger(),
),
this.audithRepo,
id,
);
const user = await service.execute(id);
// const user = await this.findUserById.execute(id);
if (!user.value) throw new NotFoundException('User not found');
const userPayload = this.userMapperForDomainAndDtos.domainTo(user.Value);
return {
Expand Down

0 comments on commit 49a45f1

Please sign in to comment.