-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (34 loc) · 1.18 KB
/
Program.cs
File metadata and controls
45 lines (34 loc) · 1.18 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
using Microsoft.EntityFrameworkCore;
using Project.API.Middlewares;
using Project.Infrastructure.Data;
using Project.API.Extensions;
var builder = WebApplication.CreateBuilder(args);
// connect db SqlServer ?
// builder.Services.AddDbContext<ApplicationDbContext>(
// options => options.UseSqlServer(builder.Configuration
// .GetConnectionString("PrimaryDbConnection")));
// connect db postgresql ?
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(
builder.Configuration.GetConnectionString("PrimaryDbConnection")));
//Register Services
builder.Services.RegisterService();
builder.Services.AddControllers();
// Register ILogger service
builder.Services.AddLogging();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Clean Structured API Project", Version = "v1" });
});
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.MapControllers();
#region Custom Middleware
app.UseRequestResponseLogging();
#endregion
app.Run();