Something went wrong. Try again.
A social knowledge tool for research trails, built on ATProto semble.so
research-tool social-network tools-for-thought atproto
Something went wrong. Try again.
1.3 kB · 41 lines
TypeScript
at development
123456789101112131415161718192021222324252627282930313233343536373839404142import { Controller } from '../../../../../shared/infrastructure/http/Controller';import { Request, Response } from 'express';import { GetCollectionsUseCase } from '../../../application/useCases/queries/GetCollectionsUseCase';import { CollectionSortField, SortOrder,} from '../../../domain/ICollectionQueryRepository';
export class GetUserCollectionsController extends Controller { constructor(private getCollectionsUseCase: GetCollectionsUseCase) { super(); }
async executeImpl(req: Request, res: Response): Promise<any> { try { const { identifier } = req.params; const { page, limit, sortBy, sortOrder, searchText } = req.query;
if (!identifier) { return this.fail(res, 'Identifier (DID or handle) is required'); }
const result = await this.getCollectionsUseCase.execute({ curatorId: identifier, page: page ? parseInt(page as string) : undefined, limit: limit ? parseInt(limit as string) : undefined, sortBy: sortBy as CollectionSortField, sortOrder: sortOrder as SortOrder, searchText: searchText as string, });
if (result.isErr()) { return this.fail(res, result.error); }
return this.ok(res, result.value); } catch (error: any) { return this.fail(res, error); } }}