Skip to content

Commit

Permalink
Clean up startup code
Browse files Browse the repository at this point in the history
Fixes #730
  • Loading branch information
ardalis committed Oct 3, 2024
1 parent e11db25 commit d91acce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace Clean.Architecture.Web.Configurations;

public static class WebApplicatonConfigs
public static class WebApplicationConfigs
{
public static async Task<IApplicationBuilder> UseWebApplicationConfigs(this WebApplication app)
public static async Task<IApplicationBuilder> UseAppMiddleware(this WebApplication app)
{
if (app.Environment.IsDevelopment())
{
Expand All @@ -23,13 +23,11 @@ public static async Task<IApplicationBuilder> UseWebApplicationConfigs(this WebA
app.UseFastEndpoints()
.UseSwaggerGen(); // Includes AddFileServer and static files middleware


app.UseHttpsRedirection();

await SeedDatabase(app);

return app;

}

static async Task SeedDatabase(WebApplication app)
Expand Down
10 changes: 4 additions & 6 deletions src/Clean.Architecture.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

builder.AddLoggerConfigs();

var microsoftLogger = new SerilogLoggerFactory(logger)
var appLogger = new SerilogLoggerFactory(logger)
.CreateLogger<Program>();

builder.Services.AddOptionConfigs(builder.Configuration, microsoftLogger, builder);
builder.Services.AddServiceConfigs(microsoftLogger, builder);
builder.Services.AddOptionConfigs(builder.Configuration, appLogger, builder);
builder.Services.AddServiceConfigs(appLogger, builder);

builder.Services.AddFastEndpoints()
.SwaggerDocument(o =>
Expand All @@ -30,11 +30,9 @@

var app = builder.Build();

await app.UseWebApplicationConfigs();

await app.UseAppMiddleware();

app.Run();


// Make the implicit Program.cs class public, so integration tests can reference the correct assembly for host building
public partial class Program { }
4 changes: 0 additions & 4 deletions src/Clean.Architecture.Web/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
Expand Down

0 comments on commit d91acce

Please sign in to comment.