-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: re-arranged / refactored to fit in solution structure
- Loading branch information
1 parent
a51db5f
commit 91713ea
Showing
21 changed files
with
271 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Applications/AdminApi/src/AdminApi/Configuration/TokensConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Backbone.Modules.Tokens.Application; | ||
|
||
namespace Backbone.AdminApi.Configuration; | ||
|
||
public class TokensConfiguration | ||
{ | ||
[Required] | ||
public ApplicationOptions Application { get; set; } = new(); | ||
|
||
[Required] | ||
public InfrastructureConfiguration Infrastructure { get; set; } = new(); | ||
|
||
public class InfrastructureConfiguration | ||
{ | ||
[Required] | ||
public SqlDatabaseConfiguration SqlDatabase { get; set; } = new(); | ||
|
||
public class SqlDatabaseConfiguration | ||
{ | ||
[Required] | ||
[MinLength(1)] | ||
[RegularExpression("SqlServer|Postgres")] | ||
public string Provider { get; set; } = string.Empty; | ||
|
||
[Required] | ||
[MinLength(1)] | ||
public string ConnectionString { get; set; } = string.Empty; | ||
|
||
[Required] | ||
public bool EnableHealthCheck { get; set; } = true; | ||
} | ||
} | ||
} |
24 changes: 11 additions & 13 deletions
24
Applications/AdminApi/src/AdminApi/Controllers/TokensController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Applications/AdminApi/src/AdminApi/Extensions/TokensServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Backbone.AdminApi.Configuration; | ||
using Backbone.Modules.Tokens.Application.Extensions; | ||
using Backbone.Modules.Tokens.Application.Infrastructure.Persistence.Repository; | ||
using Backbone.Modules.Tokens.Infrastructure.Persistence.Database; | ||
using Backbone.Modules.Tokens.Infrastructure.Persistence.Repository; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Backbone.AdminApi.Extensions; | ||
|
||
public static class TokensServiceCollectionExtensions | ||
{ | ||
public static IServiceCollection AddTokens(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddApplication(configuration.GetSection("Application")); | ||
|
||
services.ConfigureAndValidate<TokensConfiguration.InfrastructureConfiguration>(configuration.GetSection("Infrastructure").Bind); | ||
|
||
var infrastructureConfiguration = services.BuildServiceProvider().GetRequiredService<IOptions<TokensConfiguration.InfrastructureConfiguration>>().Value; | ||
|
||
services.AddDatabase(options => | ||
{ | ||
options.Provider = infrastructureConfiguration.SqlDatabase.Provider; | ||
options.DbConnectionString = infrastructureConfiguration.SqlDatabase.ConnectionString; | ||
}); | ||
|
||
// Note: Registration required. Only Modules have their used repositories registered in the DI container. | ||
services.AddTransient<ITokensRepository, TokensRepository>(); | ||
|
||
return services; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
Applications/AdminApi/src/AdminApi/Queries/GetAllTokens/GetTokensQuery.cs
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
Applications/AdminApi/src/AdminApi/Queries/GetAllTokens/GetTokensResponse.cs
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
Applications/AdminApi/src/AdminApi/Queries/GetAllTokens/Handler.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.