This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

semble / src / modules / cards / infrastructure / http / controllers / GetOpenCollectionsWithContributorController.ts
1.4 kB 43 lines
1import { Controller } from '../../../../../shared/infrastructure/http/Controller'; 2import { Request, Response } from 'express'; 3import { GetOpenCollectionsWithContributorUseCase } from '../../../application/useCases/queries/GetOpenCollectionsWithContributorUseCase'; 4import { 5 CollectionSortField, 6 SortOrder, 7} from '../../../domain/ICollectionQueryRepository'; 8 9export class GetOpenCollectionsWithContributorController extends Controller { 10 constructor( 11 private getOpenCollectionsWithContributorUseCase: GetOpenCollectionsWithContributorUseCase, 12 ) { 13 super(); 14 } 15 16 async executeImpl(req: Request, res: Response): Promise<any> { 17 try { 18 const { identifier } = req.params; 19 const { page, limit, sortBy, sortOrder } = req.query; 20 21 if (!identifier) { 22 return this.fail(res, 'Identifier (DID or handle) is required'); 23 } 24 25 const result = 26 await this.getOpenCollectionsWithContributorUseCase.execute({ 27 contributorId: identifier, 28 page: page ? parseInt(page as string) : undefined, 29 limit: limit ? parseInt(limit as string) : undefined, 30 sortBy: sortBy as CollectionSortField, 31 sortOrder: sortOrder as SortOrder, 32 }); 33 34 if (result.isErr()) { 35 return this.fail(res, result.error); 36 } 37 38 return this.ok(res, result.value); 39 } catch (error: any) { 40 return this.fail(res, error); 41 } 42 } 43}