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 · 39 lines
TypeScript
at development
12345678910111213141516171819202122232425262728293031323334353637383940import { Controller } from '../../../../../shared/infrastructure/http/Controller';import { Response } from 'express';import { CreateCollectionUseCase } from '../../../application/useCases/commands/CreateCollectionUseCase';import { AuthenticatedRequest } from '../../../../../shared/infrastructure/http/middleware/AuthMiddleware';
export class CreateCollectionController extends Controller { constructor(private createCollectionUseCase: CreateCollectionUseCase) { super(); }
async executeImpl(req: AuthenticatedRequest, res: Response): Promise<any> { try { const { name, description } = req.body; const curatorId = req.did;
if (!curatorId) { return this.unauthorized(res); }
if (!name) { return this.badRequest(res, 'Collection name is required'); }
const result = await this.createCollectionUseCase.execute({ name, description, curatorId, });
if (result.isErr()) { return this.fail(res, result.error); }
return this.ok(res, result.value); } catch (error: any) { return this.fail(res, error); } }}