-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
65 lines (50 loc) · 1.88 KB
/
Copy pathProgram.cs
File metadata and controls
65 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using AspCoreApi.Configuration;
using Serilog;
namespace AspCoreApi;
public class Program
{
public static async Task Main(string[] args)
{
// Configure Serilog first, before any services are built
LoggingConfiguration.ConfigureLogger();
try
{
Log.Information("Starting web application");
var builder = WebApplication.CreateBuilder(args);
// Add Serilog to the application
builder.Host.UseSerilog();
// Configure all services using extension methods
builder.Services
.AddApplicationLogging()
.AddApplicationDatabase(builder.Configuration, builder.Environment)
.AddApplicationIdentity(builder.Configuration)
.AddApplicationSecurity(builder.Configuration)
.AddApplicationSwagger()
.AddResponseKompres()
.AddApplicationRateLimiting()
.AddApplicationCors(builder.Configuration)
.AddProblemDetails()
.AddControllers();
// Add health checks separately since it returns IHealthChecksBuilder
builder.Services.AddHealthChecks();
// Add HTTP client and other services
builder.Services.AddHttpClients();
// Configure service validation based on environment
builder.ConfigureServiceValidation();
var app = builder.Build();
// Configure middleware pipeline
app.ConfigureApplicationPipeline(builder.Environment);
// Pastikan seeding tidak menghentikan Build Migrasi
// await app.SeedDatabase();
app.Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Application terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}
}
}