-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
46 lines (37 loc) · 989 Bytes
/
Program.cs
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
using TodoApi.Configure;
using TodoApi.Todos.Endpoints;
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateBootstrapLogger();
Log.Information("Starting up");
try
{
var builder = WebApplication.CreateBuilder(args)
.AddCustomSerilog()
.AddCustomDependencies()
.AddCustomPersistence()
.AddCustomExceptionHandling()
.AddCustomSwagger()
.AddCustomAuthnAndAuthz();
var application = builder.Build()
.UseCustomSerilog()
.UseCustomExceptionHandling()
.UseCustomSwagger()
.UseCustomAuthnAndAuthz()
.MapTodoEndpoints();
await application.EnsureDbCreated();
application.Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "An exception was thrown during startup");
return 1;
}
finally
{
Log.Information("Shut down complete");
Log.CloseAndFlush();
}
// needed to allow WebApplicationFactory<Program> in tests
public partial class Program { }