Spaces:
Sleeping
Sleeping
Download src/ClipForge.Api/Endpoints/IdeaEndpoints.cs from clipeforge/app: direct link, hf CLI and curl.
- Browser
- Download file 2.09 kB
-
https://huggingface.co/spaces/clipeforge/app/resolve/main/src/ClipForge.Api/Endpoints/IdeaEndpoints.cs
- Command line
-
hf download hf://spaces/clipeforge/app/src/ClipForge.Api/Endpoints/IdeaEndpoints.cs
-
curl -L -o IdeaEndpoints.cs https://huggingface.co/spaces/clipeforge/app/resolve/main/src/ClipForge.Api/Endpoints/IdeaEndpoints.cs
2.09 kB
| using ClipForge.Contracts.Requests; | |
| using ClipForge.Contracts.Responses; | |
| using ClipForge.Core.Interfaces; | |
| using ClipForge.Core.Interfaces.Services; | |
| namespace ClipForge.Api.Endpoints; | |
| public static class IdeaEndpoints | |
| { | |
| public static void MapIdeaEndpoints(this WebApplication app) | |
| { | |
| var group = app.MapGroup("/api/ideas").WithTags("Ideas"); | |
| group.MapPost("/generate", async (GenerateIdeaRequest request, IIdeaGenerationService service) => | |
| { | |
| if (request.Count > 1) | |
| { | |
| var ideas = await service.GenerateBatchIdeasAsync(request.Niche, request.Count, request.Platform); | |
| return Results.Ok(ideas.Select(MapToResponse)); | |
| } | |
| var idea = await service.GenerateIdeaAsync(request.Niche, request.Platform); | |
| return Results.Ok(MapToResponse(idea)); | |
| }); | |
| group.MapGet("/", async (IVideoIdeaRepository repository) => | |
| { | |
| var ideas = await repository.GetAllAsync(); | |
| return Results.Ok(ideas.Select(MapToResponse)); | |
| }); | |
| group.MapGet("/{id:guid}", async (Guid id, IVideoIdeaRepository repository) => | |
| { | |
| var idea = await repository.GetByIdAsync(id); | |
| return idea is null ? Results.NotFound() : Results.Ok(MapToResponse(idea)); | |
| }); | |
| group.MapGet("/status/{status}", async (string status, IVideoIdeaRepository repository) => | |
| { | |
| var ideas = await repository.GetByStatusAsync(status); | |
| return Results.Ok(ideas.Select(MapToResponse)); | |
| }); | |
| group.MapGet("/niche/{niche}", async (string niche, IVideoIdeaRepository repository) => | |
| { | |
| var ideas = await repository.GetByNicheAsync(niche); | |
| return Results.Ok(ideas.Select(MapToResponse)); | |
| }); | |
| } | |
| private static VideoIdeaResponse MapToResponse(ClipForge.Core.Entities.VideoIdea idea) => new( | |
| idea.Id, idea.Topic, idea.Title, idea.Hook, idea.TargetAudience, | |
| idea.Platform, idea.Status, idea.Niche, idea.Tags, idea.CreatedAt); | |
| } | |