Skip to content

Commit

Permalink
Refactor/nuget upgrade (#74)
Browse files Browse the repository at this point in the history
* Restructure folders

* Refactor WebApiEndpoint to use TResponse instead of TViewModel
  • Loading branch information
ricksu978 committed Jan 19, 2024
1 parent b14eeb6 commit 612f7b6
Show file tree
Hide file tree
Showing 135 changed files with 114 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ private static IServiceCollection AddUseCases(this IServiceCollection services)
{
if (type.BaseType?.IsGenericType == true && type.BaseType?.GetGenericTypeDefinition() == useCaseType)
{
// services.AddScoped<UseCase<TRequest, TResponse>, ImplementType>();
services.AddScoped(type.BaseType, type);
}
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<None Remove="UseCases\NewFile1.txt" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Wsa.Gaas.Werewolf.Application.Common;

namespace Wsa.Gaas.Werewolf.EntityFrameworkCore;
namespace Wsa.Gaas.Werewolf.SqlServer;
public static class DependencyInjection
{
public static IServiceCollection AddEntityFrameworkCoreRepository(this IServiceCollection services)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Domain.Objects;

namespace Wsa.Gaas.Werewolf.EntityFrameworkCore;
namespace Wsa.Gaas.Werewolf.SqlServer;
public class InMemoryRepository : IRepository
{
private readonly Dictionary<ulong, Game> _discordIdMemory = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Domain.Objects;

namespace Wsa.Gaas.Werewolf.EntityFrameworkCore;
public class EntityFrameworkCoreRepository : DbContext, IRepository
namespace Wsa.Gaas.Werewolf.SqlServer;
public class SqlServerRepository : DbContext, IRepository
{
public EntityFrameworkCoreRepository(DbContextOptions opt) : base(opt)
public SqlServerRepository(DbContextOptions opt) : base(opt)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Wsa.Gaas.Werewolf.Domain.Objects;

namespace Wsa.Gaas.Werewolf.EntityFrameworkCore.TypeConfigurations;
namespace Wsa.Gaas.Werewolf.SqlServer.TypeConfigurations;
internal class GameTypeConfiguration : IEntityTypeConfiguration<Game>
{
public void Configure(EntityTypeBuilder<Game> builder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Wsa.Gaas.Werewolf.Domain.Objects;

namespace Wsa.Gaas.Werewolf.EntityFrameworkCore.TypeConfigurations;
namespace Wsa.Gaas.Werewolf.SqlServer.TypeConfigurations;
internal class PlayerTypeConfiguration : IEntityTypeConfiguration<Player>
{
public void Configure(EntityTypeBuilder<Player> builder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Wsa.Gaas.Werewolf.Domain.Objects;
using Wsa.Gaas.Werewolf.Domain.Objects.Roles;

namespace Wsa.Gaas.Werewolf.EntityFrameworkCore.TypeConfigurations;
namespace Wsa.Gaas.Werewolf.SqlServer.TypeConfigurations;
internal class RoleTypeConfiguration : IEntityTypeConfiguration<Role>
, IEntityTypeConfiguration<Domain.Objects.Roles.Werewolf>
, IEntityTypeConfiguration<AlphaWerewolf>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Application\Wsa.Gaas.Werewolf.Application.csproj" />
<ProjectReference Include="..\..\Core\Application\Wsa.Gaas.Werewolf.Application.csproj" />
</ItemGroup>

</Project>
13 changes: 0 additions & 13 deletions src/BackEnd/src/InterfaceAdapter/WebApi/Common/WebApiEndpoint.cs

This file was deleted.

13 changes: 13 additions & 0 deletions src/BackEnd/src/Presentation/WebApi/Common/WebApiEndpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using FastEndpoints;
using Wsa.Gaas.Werewolf.Application.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Common;
public abstract class WebApiEndpoint<TRequest, TResponse> : Endpoint<TRequest, TResponse>
where TRequest : notnull, new()
where TResponse : notnull
{
public required UseCase<TRequest, TResponse> UseCase { get; set; }

public abstract override Task<TResponse> ExecuteAsync(TRequest req, CancellationToken ct);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.Options;

namespace Wsa.Gaas.Werewolf.Application;
namespace Wsa.Gaas.Werewolf.WebApi;
public static class DependencyInjection
{
public static IServiceCollection AddWebApi(this IServiceCollection services, IConfiguration configuration)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;

public class ConfirmPlayerRoleEndpoint : WebApiEndpoint<ConfirmPlayerRoleRequest, ConfirmPlayerRoleResponse>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;
public class CreateGameEndpoint : WebApiEndpoint<CreateGameRequest, CreateGameResponse>
{
public override void Configure()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;
public class DiscoverPlayerRoleEndpoint : WebApiEndpoint<DiscoverPlayerRoleRequest, DiscoverPlayerRoleResponse>
{
public override void Configure()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;
public class EndGameEndpoint : WebApiEndpoint<EndGameRequest, EndGameResponse>
{
public override void Configure()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;

public class GetGameEndpoint : WebApiEndpoint<GetGameRequest, GetGameResponse>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.Application;
namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;
public class StartGameEndpoint : WebApiEndpoint<StartGameRequest, StartGameResponse>
{
public override void Configure()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;
public class WerewolfVoteEndpoint : WebApiEndpoint<WerewolfVoteRequest, WerewolfVoteResponse>
{
public override void Configure()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;
public class WitchUseAntidoteEndpoint : WebApiEndpoint<WitchUseAntidoteRequest, WitchUseAntidoteResponse>
{
public override void Configure()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.WebApi.Common;

namespace Wsa.Gaas.Werewolf.WebApi.Endpoints;


public class WitchUsePoisonEndpoint : WebApiEndpoint<WitchUsePoisonRequest, WitchUsePoisonResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Wsa.Gaas.Werewolf.Domain.Common;
using Wsa.Gaas.Werewolf.Domain.Exceptions;

namespace Wsa.Gaas.Werewolf.Application;
namespace Wsa.Gaas.Werewolf.WebApi.Extensions;
public static class ExceptionHandlerExtensions
{
public static IApplicationBuilder UseJsonExceptionHandler(this IApplicationBuilder app, ILogger? logger = null, bool logStructuredException = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using Microsoft.AspNetCore.SignalR;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Domain.Common;
using Wsa.Gaas.Werewolf.WebApi.ViewModels;

namespace Wsa.Gaas.Werewolf.Application;
namespace Wsa.Gaas.Werewolf.WebApi;
/**
* https://learn.microsoft.com/en-us/aspnet/core/signalr/hubs?view=aspnetcore-7.0#create-and-use-hubs-3
* > Hubs are transient:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Text.Json.Serialization;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.EntityFrameworkCore;
using Wsa.Gaas.Werewolf.SqlServer;
using Wsa.Gaas.Werewolf.WebApi;
using Wsa.Gaas.Werewolf.WebApi.Extensions;

var builder = WebApplication.CreateBuilder(args);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Wsa.Gaas.Werewolf.Domain.Objects;

namespace Wsa.Gaas.Werewolf.Application;
namespace Wsa.Gaas.Werewolf.WebApi.ViewModels;
public class GameVm
{
public string Id { get; set; } = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Wsa.Gaas.Werewolf.Domain.Objects;

namespace Wsa.Gaas.Werewolf.Application;
namespace Wsa.Gaas.Werewolf.WebApi.ViewModels;
public class PlayerVm
{
public string Id { get; set; } = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Wsa.Gaas.Werewolf.Application;
namespace Wsa.Gaas.Werewolf.WebApi;
public static class WebApiDefaults
{
public const string SignalrEndpoint = "/events"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,17 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<None Remove="Endpoints\NewFile.txt" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints" Version="5.21.2" />
<ItemGroup>
<PackageReference Include="FastEndpoints.Swagger" Version="5.21.2" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Application\Wsa.Gaas.Werewolf.Application.csproj" />
<ProjectReference Include="..\EntityFrameworkCore\Wsa.Gaas.Werewolf.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\Infrastructure\SqlServer\Wsa.Gaas.Werewolf.SqlServer.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks.Dataflow;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.Options;
using Wsa.Gaas.Werewolf.Domain.Common;
using Wsa.Gaas.Werewolf.WebApi;
using Wsa.Gaas.Werewolf.WebApi.ViewModels;
using Wsa.Gaas.Werewolf.WebApiTests.Common;

namespace Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using FastEndpoints;
using System.Threading.Tasks.Dataflow;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.UseCases;
using Wsa.Gaas.Werewolf.Domain.Objects;
using Wsa.Gaas.Werewolf.WebApi.Endpoints;
using Wsa.Gaas.Werewolf.WebApi.ViewModels;
using Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;

namespace Wsa.Gaas.Werewolf.WebApiTests.ATDD.GameTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using FastEndpoints;
using System.Net;
using System.Threading.Tasks.Dataflow;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.UseCases;
using Wsa.Gaas.Werewolf.Domain.Events;
using Wsa.Gaas.Werewolf.WebApi.Endpoints;
using Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;

namespace Wsa.Gaas.Werewolf.WebApiTests.ATDD.GameTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using FastEndpoints;
using System.Net;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.UseCases;
using Wsa.Gaas.Werewolf.Domain.Events;
using Wsa.Gaas.Werewolf.WebApi.Endpoints;
using Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;

namespace Wsa.Gaas.Werewolf.WebApiTests.ATDD.GameTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using FastEndpoints;
using System.Net;
using System.Threading.Tasks.Dataflow;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.UseCases;
using Wsa.Gaas.Werewolf.Domain.Events;
using Wsa.Gaas.Werewolf.Domain.Objects;
using Wsa.Gaas.Werewolf.WebApi.Endpoints;
using Wsa.Gaas.Werewolf.WebApi.ViewModels;
using Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;

namespace Wsa.Gaas.Werewolf.WebApiTests.ATDD.GameTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FastEndpoints;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.UseCases;
using Wsa.Gaas.Werewolf.Domain.Objects;
using Wsa.Gaas.Werewolf.WebApi.Endpoints;
using Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;

namespace Wsa.Gaas.Werewolf.WebApiTests.ATDD.GameTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using FastEndpoints;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.UseCases;
using Wsa.Gaas.Werewolf.Domain.Events;
using Wsa.Gaas.Werewolf.Domain.Objects;
using Wsa.Gaas.Werewolf.Domain.Objects.Roles;
using Wsa.Gaas.Werewolf.WebApi.Endpoints;
using Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;

namespace Wsa.Gaas.Werewolf.WebApiTests.ATDD.GameTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using FastEndpoints;
using System.Net;
using System.Net.Http.Json;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.UseCases;
using Wsa.Gaas.Werewolf.Domain.Objects;
using Wsa.Gaas.Werewolf.WebApi.Endpoints;
using Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;

/* Game
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using FastEndpoints;
using Wsa.Gaas.Werewolf.Application;
using Wsa.Gaas.Werewolf.Application.Common;
using Wsa.Gaas.Werewolf.Application.UseCases;
using Wsa.Gaas.Werewolf.Domain.Objects;
using Wsa.Gaas.Werewolf.Domain.Objects.Roles;
using Wsa.Gaas.Werewolf.WebApi.Endpoints;
using Wsa.Gaas.Werewolf.WebApiTests.ATDD.Common;

namespace Wsa.Gaas.Werewolf.WebApiTests.ATDD.GameTests;
Expand Down
Loading

0 comments on commit 612f7b6

Please sign in to comment.