-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (38 loc) · 1.06 KB
/
Program.cs
File metadata and controls
47 lines (38 loc) · 1.06 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
using Microsoft.EntityFrameworkCore;
using FlaggedBooks.Extensions;
using FlaggedBooks.Endpoints;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowMyFrontend", policy =>
{
policy.WithOrigins("http://127.0.0.1:5500")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
builder.Services.AddOpenApi();
builder.Services.AddResponseCaching();
builder.Services.AddApplicationServices(builder.Configuration);
var app = builder.Build();
// Initialize database
await app.InitializeDatabaseAsync();
// Configure the HTTP request pipeline
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseHttpsRedirection();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseResponseCaching();
app.UseCors("AllowMyFrontend");
app.UseSession();
// Map all endpoints
app.MapAuthEndpoints();
app.MapBookEndpoints();
app.MapChatEndpoints();
app.MapLectureClubEndpoints();
app.MapUserBooksEndpoints();
app.MapUserProfileEndpoints();
app.Run();