This repository has no description
semble
/
src
/
modules
/
cards
/
infrastructure
/
http
/
controllers
/
GetCollectionFollowersCountController.ts
982 B
33 lines
1import { Controller } from '../../../../../shared/infrastructure/http/Controller';
2import { Request, Response } from 'express';
3import { GetCollectionFollowersCountUseCase } from '../../../../user/application/useCases/queries/GetCollectionFollowersCountUseCase';
4
5export class GetCollectionFollowersCountController extends Controller {
6 constructor(
7 private getCollectionFollowersCountUseCase: GetCollectionFollowersCountUseCase,
8 ) {
9 super();
10 }
11
12 async executeImpl(req: Request, res: Response): Promise<any> {
13 try {
14 const { collectionId } = req.params;
15
16 if (!collectionId) {
17 return this.fail(res, 'Collection ID is required');
18 }
19
20 const result = await this.getCollectionFollowersCountUseCase.execute({
21 collectionId,
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}