-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
91 lines (69 loc) · 2.38 KB
/
Program.cs
File metadata and controls
91 lines (69 loc) · 2.38 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var builder = WebApplication.CreateBuilder(args);
//DATABASE CONNECTION
builder.Services.AddDbContext<MBDEVproAPIDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
// SERVICES
builder.Services.AddTransient<ICustomerService, CustomerService>();
// REPOSITORIES
builder.Services.AddTransient<ICustomerRepository, CustomerRepository>();
builder.Services.AddControllers();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
// Register the Swagger generator; custom details
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "MBDEVproAPI v1 | .NET CORE 10",
Description = "manages business customers",
TermsOfService = new Uri("https://images3.alphacoders.com/967/thumb-1920-96797.jpg"),
Contact = new OpenApiContact
{
Name = "MBDEVproAPI Administrator",
Email = "[email protected]",
Url = new Uri("https://m.media-amazon.com/images/I/71rVfyrUzPL._SL1101_.jpg"),
},
License = new OpenApiLicense
{
Name = "No license",
Url = new Uri("https://example.com/license"),
}
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
Log.Information("MBDEVproAPI: (Development Environment)");
app.UseDeveloperExceptionPage();
}
if (app.Environment.EnvironmentName == "Test")
{
Log.Information("MBDEVproAPI: Test Environment)");
}
if (app.Environment.EnvironmentName == "Uat")
{
Log.Information("MBDEVproAPI: Uat Environment)");
}
if (app.Environment.EnvironmentName == "Production")
{
Log.Information("MBDEVproAPI: Production Environment)");
}
if (app.Environment.IsDevelopment() || app.Environment.EnvironmentName == "Test")
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
//c.SwaggerEndpoint("/MBDEVproAPI/swagger/v1/swagger.json", "MBDEVproAPI v1 .NET CORE 10");
c.SwaggerEndpoint("../swagger/v1/swagger.json", "MBDEVproAPI v1 .NET CORE 10");
// ENDPOINTS: https://localhost:7092/swagger/index.html
// JSON: https://localhost:7092/swagger/v1/swagger.json
});
}
//Middleware
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();