-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (33 loc) · 1.11 KB
/
Program.cs
File metadata and controls
40 lines (33 loc) · 1.11 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
// Imports
using Flowboard_Project_Management_System_Backend.Services;
using Flowboard_Project_Management_System_Backend.Configurations;
using DotNetEnv;
using System.Text.Json;
// Builder
var builder = WebApplication.CreateBuilder(args);
Env.Load();
builder.Services.AddFrontendCors(builder.Environment);
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
// Use camelCase for JSON property names to match frontend expectations
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
});
builder.Services.AddOpenApi();
builder.Services.AddSingleton<MongoDbService>();
builder.Services.AddScoped<IAnalyticsService, AnalyticsService>();
builder.Services.AddJwtAuthentication();
var app = builder.Build();
// For Open API
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseCors("AllowFrontend");
app.UseHttpsRedirection();
// ---------------- Enable Authentication ----------------
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();