Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Faura.Infrastructure.ApiBoostraper.Extensions;

using Faura.Configurations;
using Microsoft.Extensions.Configuration;

public static class ConfigurationExtensions
{
public static void ConfigureUserSecrets<T>(this IConfigurationBuilder configBuilder)
where T : class
{
if(FauraEnvironment.IsLocal || FauraEnvironment.IsDevelopment)
{
configBuilder.AddUserSecrets<T>(optional: true);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace Faura.Infrastructure.ApiBoostraper.Extensions;

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

public static class WebApplicationBuilderExtensions
{

public static WebApplicationBuilder BootstrapCommonFauraServices(this WebApplicationBuilder builder)
{
builder.Services.ConfigureControllers();
Expand All @@ -16,4 +17,10 @@ public static WebApplicationBuilder BootstrapCommonFauraServices(this WebApplica
builder.Services.AddHeadersPropagation(builder.Configuration);
return builder;
}

public static void RegisterSettingsProvider<T>(this IHostApplicationBuilder builder) where T : class
{
builder.Configuration.AddEnvironmentVariables();
builder.Configuration.ConfigureUserSecrets<T>();
}
}
3 changes: 3 additions & 0 deletions src/Templates/Faura.WebAPI/Boostrappers/ApiBoostrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

using Faura.Infrastructure.Logger;
using Faura.Infrastructure.JWT.Extensions;
using Faura.Infrastructure.ApiBoostraper.Extensions;

public static class ApiBoostrapper
{
public static WebApplicationBuilder RegisterDependencies(this WebApplicationBuilder builder)
{
builder.RegisterSettingsProvider<Program>();
builder.BootstrapCommonFauraServices();
builder.Host.SetupLogging();
builder.Services.SetUpJwt(builder.Configuration);

Expand Down
1 change: 1 addition & 0 deletions src/Templates/Faura.WebAPI/Faura.WebAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>bc927e2b-51aa-47ca-b33f-8175e77799fa</UserSecretsId>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 0 additions & 6 deletions src/Templates/Faura.WebAPI/Faura.WebAPI.http

This file was deleted.

3 changes: 2 additions & 1 deletion src/Templates/Faura.WebAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

var builder = WebApplication.CreateBuilder(args);

builder.BootstrapCommonFauraServices();
var a = builder.Configuration.Sources;

builder.RegisterDependencies();
builder.RegisterApplicationDependencies();

Expand Down
9 changes: 6 additions & 3 deletions src/Templates/Faura.WebAPI/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5069",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Local",
"FAURA_ENVIRONMENT": "Development"
}
},
"https": {
Expand All @@ -26,15 +27,17 @@
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7140;http://localhost:5069",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Local",
"FAURA_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Local",
"FAURA_ENVIRONMENT": "Development"
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Templates/Faura.WebAPI/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
},


"JWT": {
"MetadataAddress": "{MetadataAddress-PlaceHolder}",
"ValidIssuer": "{ValidIssuer-PlaceHolder}",
"Audience": "account"
},
"JWT": {
"MetadataAddress": "http://localhost:18080/realms/nexus/.well-known/openid-configuration",
"ValidIssuer": "http://localhost:18080/realms/nexus",
"Audience": "account"
},

"ConnectionStrings": {
"Employee": "{connectionString_placeholder}"
Expand Down
67 changes: 53 additions & 14 deletions src/Templates/Faura.WebAPI/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,56 @@
{
"Logging": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Error",
"System": "Error"
}
},
"Outputs": {
"Console": {
"Enable": true
}
}
"Logging": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Error",
"System": "Error"
}
},
"AllowedHosts": "*"
"ApplicationName": "FauraApp",
"Outputs": {
"Console": {
"Enable": true,
"LogTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj} | CorrelationId: {CorrelationId} | ApplicationName: {ApplicationName}{NewLine}{Exception}"
}
}
},

"Swagger": {
"Authentication": {
"OAuth2": {
"Enable": true,
"Name": "OAuth2",
"AuthenticationURL": "{AuthenticationURL-PlaceHolder}",
"Scopes": {
"openid": "openid",
"profile": "profile"
}
},
"Bearer": {
"Enable": true,
"Name": "Bearer"
},
"BasicAuth": {
"Enable": false,
"Name": "Basic"
},
"ApiKey": {
"Enable": false,
"Name": "X-API-Key",
"In": "Header" // "Header" o "Query"
}
}
},


"JWT": {
"MetadataAddress": "http://localhost:18080/realms/nexus/.well-known/openid-configuration",
"ValidIssuer": "http://localhost:18080/realms/nexus",
"Audience": "account"
},

"ConnectionStrings": {
"Employee": "{connectionString_placeholder}"
}
}
Loading