refactor: standardize project names to Musify.* and flatten layout
- Flatten nested per-repo folders into flat Musify.* projects at root - Rename assemblies/csproj: Domain->Musify.Domain, Application->Musify.Application, Infrastructure->Musify.Infrastructure, WebApi->Musify.Api, Worker->Musify.Worker, StreamingGateway->Musify.StreamingGateway - Rename WebApi.* namespaces to Musify.Api.* - Update all ProjectReference paths and the solution file - Consolidate stray per-repo dotfiles; add root .gitattributes - Move flutter client out to _archive
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Ardalis.Result;
|
||||
using IResult = Microsoft.AspNetCore.Http.IResult;
|
||||
|
||||
namespace Musify.Api.Extensions;
|
||||
|
||||
public static class ResultHttpExtensions
|
||||
{
|
||||
public static IResult ToHttpResult(this Result result) =>
|
||||
result.Status switch
|
||||
{
|
||||
ResultStatus.Ok or ResultStatus.NoContent => Results.NoContent(),
|
||||
ResultStatus.NotFound => Results.NotFound(result.Errors.FirstOrDefault()),
|
||||
ResultStatus.Invalid => Results.ValidationProblem(ToValidationDictionary(result.ValidationErrors)),
|
||||
ResultStatus.Unauthorized => Results.Unauthorized(),
|
||||
ResultStatus.Forbidden => Results.StatusCode(StatusCodes.Status403Forbidden),
|
||||
ResultStatus.Conflict => Results.Conflict(result.Errors.FirstOrDefault()),
|
||||
_ => Results.Problem(string.Join(", ", result.Errors))
|
||||
};
|
||||
|
||||
public static IResult ToHttpResult<T>(this Result<T> result) =>
|
||||
result.Status switch
|
||||
{
|
||||
ResultStatus.Ok => Results.Ok(result.Value),
|
||||
ResultStatus.NotFound => Results.NotFound(result.Errors.FirstOrDefault()),
|
||||
ResultStatus.Invalid => Results.ValidationProblem(ToValidationDictionary(result.ValidationErrors)),
|
||||
ResultStatus.Unauthorized => Results.Unauthorized(),
|
||||
ResultStatus.Forbidden => Results.StatusCode(StatusCodes.Status403Forbidden),
|
||||
ResultStatus.Conflict => Results.Conflict(result.Errors.FirstOrDefault()),
|
||||
_ => Results.Problem(string.Join(", ", result.Errors))
|
||||
};
|
||||
|
||||
private static Dictionary<string, string[]> ToValidationDictionary(IEnumerable<ValidationError> errors) =>
|
||||
errors
|
||||
.GroupBy(e => string.IsNullOrEmpty(e.Identifier) ? "general" : e.Identifier)
|
||||
.ToDictionary(g => g.Key, g => g.Select(e => e.ErrorMessage).ToArray());
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using FluentValidation;
|
||||
using Musify.Infrastructure.MassTransit;
|
||||
using Musify.Infrastructure.Persistence;
|
||||
using Musify.Application.Configuration;
|
||||
using Musify.Infrastructure.Services;
|
||||
using Musify.Api.Authentication;
|
||||
using Musify.Api.DataTransferObjects.PlayLists;
|
||||
using Musify.Api.OpenApi;
|
||||
using Musify.Api.Scalar;
|
||||
|
||||
namespace Musify.Api.Extensions;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddDatabase(configuration);
|
||||
services.AddApplicationStorageConfiguration(configuration);
|
||||
services.AddPlayListConfiguration(configuration);
|
||||
services.AddTrackConfiguration(configuration);
|
||||
services.AddStreamGatewayConfiguration(configuration);
|
||||
services.AddStorageService(configuration);
|
||||
services.AddStreamTicketService(configuration);
|
||||
services.AddUploadIntentConfiguration(configuration);
|
||||
services.AddMassTransitClient(configuration);
|
||||
services.AddMediator();
|
||||
services.AddAuthenticationConfiguration(configuration);
|
||||
services.AddOpenApiConfiguration();
|
||||
services.AddScalarConfiguration();
|
||||
services.AddValidatorsFromAssemblyContaining<CreatePlayListRequest>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user