A social knowledge tool for researchers built on ATProto
1import { Controller } from '../../../../../shared/infrastructure/http/Controller';
2import { Request, Response } from 'express';
3import { GetCollectionsForUrlUseCase } from '../../../application/useCases/queries/GetCollectionsForUrlUseCase';
4
5export class GetCollectionsForUrlController extends Controller {
6 constructor(
7 private getCollectionsForUrlUseCase: GetCollectionsForUrlUseCase,
8 ) {
9 super();
10 }
11
12 async executeImpl(req: Request, res: Response): Promise<any> {
13 try {
14 const { url } = req.query;
15
16 if (!url || typeof url !== 'string') {
17 return this.badRequest(res, 'URL query parameter is required');
18 }
19
20 const result = await this.getCollectionsForUrlUseCase.execute({
21 url,
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}