Reorganize backend to mirror Musify.slnx folder structure
Moves the six backend projects on disk into Core/ and Hosts/ subfolders, matching the solution folders already defined in Musify.slnx, so the file explorer reflects the same layout as the solution: backend/Core/Musify.Domain backend/Core/Musify.Application backend/Core/Musify.Infrastructure backend/Hosts/Musify.Api backend/Hosts/Musify.Worker backend/Hosts/Musify.StreamingGateway Updates every reference to the old paths: ProjectReference entries in Musify.Api.csproj and Musify.Worker.csproj, the three Dockerfiles, deploy/scripts/migrate.ps1|sh, deploy/zitadel/provision.ps1, deploy/up.ps1, deploy/README.md and docs/development.md. Also fixes a stale Dockerfile comment pointing at a compose file that no longer exists. Verified with `dotnet build Musify.slnx` against the new layout.
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
using Mediator;
|
||||
using Musify.Api.Authentication;
|
||||
using Musify.Api.Extensions;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.YouTube;
|
||||
using Musify.Application.YouTube.Responses;
|
||||
|
||||
namespace Musify.Api.Endpoints;
|
||||
|
||||
public static class YouTubeEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapYouTubeEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.MapGroup("/youtube")
|
||||
.WithTags("YouTube");
|
||||
|
||||
group.MapGet("/search", SearchTracks)
|
||||
.WithName("SearchYouTubeTracks")
|
||||
.WithSummary("Search Songs On YouTube Music.")
|
||||
.RequireAuthorization()
|
||||
.Produces<YouTubeSearchResult>()
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.ProducesValidationProblem();
|
||||
|
||||
group.MapGet("/albums", SearchAlbums)
|
||||
.WithName("SearchYouTubeAlbums")
|
||||
.WithSummary("Search Albums On YouTube Music.")
|
||||
.RequireAuthorization()
|
||||
.Produces<YouTubeAlbumSearchResult>()
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.ProducesValidationProblem();
|
||||
|
||||
group.MapGet("/albums/{albumId}", GetAlbum)
|
||||
.WithName("GetYouTubeAlbum")
|
||||
.WithSummary("Get A YouTube Music Album With Its Tracklist.")
|
||||
.RequireAuthorization()
|
||||
.Produces<YouTubeAlbumDetail>()
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces(StatusCodes.Status404NotFound);
|
||||
|
||||
group.MapGet("/tracks/{videoId}/stream", GetTrackStream)
|
||||
.WithName("GetYouTubeTrackStream")
|
||||
.WithSummary("Resolve Playback For A YouTube Track: Server Stream If Downloaded, Direct YouTube Stream Otherwise.")
|
||||
.RequireAuthorization()
|
||||
.Produces<YouTubeStreamResponse>()
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces(StatusCodes.Status404NotFound);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetTrackStream(
|
||||
IMediator mediator,
|
||||
CurrentUser currentUser,
|
||||
string videoId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await mediator.Send(
|
||||
new ResolveYouTubeTrackStreamCommand(videoId, currentUser.RequiredId),
|
||||
cancellationToken);
|
||||
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> SearchAlbums(
|
||||
IMediator mediator,
|
||||
CancellationToken cancellationToken,
|
||||
string query,
|
||||
string? continuation = null)
|
||||
{
|
||||
var result = await mediator.Send(
|
||||
new SearchYouTubeAlbumsQuery(query, continuation ?? string.Empty),
|
||||
cancellationToken);
|
||||
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetAlbum(
|
||||
IMediator mediator,
|
||||
string albumId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await mediator.Send(new GetYouTubeAlbumQuery(albumId), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> SearchTracks(
|
||||
IMediator mediator,
|
||||
CancellationToken cancellationToken,
|
||||
string query,
|
||||
string? continuation = null)
|
||||
{
|
||||
var result = await mediator.Send(
|
||||
new SearchYouTubeTracksQuery(query, continuation ?? string.Empty),
|
||||
cancellationToken);
|
||||
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user