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.2 kB · 40 lines
TypeScript
at development
1234567891011121314151617181920212223242526272829303132333435363738394041import { Controller } from '../../../../../shared/infrastructure/http/Controller';import { Response } from 'express';import { AddUrlToLibraryUseCase } from '../../../application/useCases/commands/AddUrlToLibraryUseCase';import { AuthenticatedRequest } from '../../../../../shared/infrastructure/http/middleware/AuthMiddleware';
export class AddUrlToLibraryController extends Controller { constructor(private addUrlToLibraryUseCase: AddUrlToLibraryUseCase) { super(); }
async executeImpl(req: AuthenticatedRequest, res: Response): Promise<any> { try { const { url, note, collectionIds } = req.body; const curatorId = req.did;
if (!curatorId) { return this.unauthorized(res); }
if (!url) { return this.badRequest(res, 'URL is required'); }
const result = await this.addUrlToLibraryUseCase.execute({ url, note, collectionIds: collectionIds || [], curatorId, });
if (result.isErr()) { return this.fail(res, result.error); }
return this.ok(res, result.value); } catch (error: any) { return this.fail(res, error); } }}