This repository has no description
959 B
33 lines
1import { Controller } from '../../../../../shared/infrastructure/http/Controller';
2import { Response } from 'express';
3import { GetProfileUseCase } from '../../../application/useCases/queries/GetProfileUseCase';
4import { AuthenticatedRequest } from '../../../../../shared/infrastructure/http/middleware/AuthMiddleware';
5
6export class GetMyProfileController extends Controller {
7 constructor(private getProfileUseCase: GetProfileUseCase) {
8 super();
9 }
10
11 async executeImpl(req: AuthenticatedRequest, res: Response): Promise<any> {
12 try {
13 const userId = req.did;
14
15 if (!userId) {
16 return this.unauthorized(res);
17 }
18
19 const result = await this.getProfileUseCase.execute({
20 userId,
21 callerDid: req.did,
22 });
23
24 if (result.isErr()) {
25 return this.fail(res, result.error);
26 }
27
28 return this.ok(res, result.value);
29 } catch (error: any) {
30 return this.fail(res, error);
31 }
32 }
33}