-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
65 lines (54 loc) · 1.68 KB
/
Copy pathProgram.cs
File metadata and controls
65 lines (54 loc) · 1.68 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 dotenv.net;
using Authentication;
using Services;
using Data.Database;
using Microsoft.AspNetCore.Authentication;
DotEnv.Load();
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApiDocument(settings =>
{
settings.Title = "RDMP API";
settings.Version = "v1";
settings.Description = "API for RDMP application";
settings.DocumentName = "v1";
});
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
builder.Services.AddDbContext<RdmpContext>();
builder.Services.AddHttpClient();
builder.Services.AddHttpClient<ITrelloService, TrelloService>();
builder.Services.AddScoped<IAIService, AIService>();
builder.Services.AddScoped<ICrawlerService, CrawlerService>();
builder.Services.AddScoped<ITrelloConnectionService, TrelloConnectionService>();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IRoadmapService, RoadmapService>();
builder.Services.AddSingleton<IJwtService, JwtService>();
builder.Services.AddControllers();
builder.Services
.AddAuthentication(options =>
{
options.DefaultScheme = "Jwt";
options.DefaultAuthenticateScheme = "Jwt";
options.DefaultChallengeScheme = "Jwt";
})
.AddScheme<AuthenticationSchemeOptions, JwtAuthenticationHandler>("Jwt", _ => { });
builder.Services.AddAuthorization();
var app = builder.Build();
app.MapGet("/health", () => "OK");
app.UseCors();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
if (app.Environment.IsDevelopment())
{
app.UseOpenApi();
app.UseSwaggerUi();
}
app.Run();