-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (37 loc) · 1.2 KB
/
Program.cs
File metadata and controls
48 lines (37 loc) · 1.2 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
using MoodMusicAPI.Services;
using MoodMusicAPI.Models;
using MoodMusicAPI.Endpoints;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins("http://localhost:5173") // your Vite dev server
.AllowAnyHeader()
.AllowAnyMethod();
});
});
// Configure Spotify and application services
builder.Services.Configure<SpotifySettings>(builder.Configuration.GetSection("Spotify"));
builder.Services.AddHttpClient();
builder.Services.AddScoped<ISpotifyService, SpotifyService>();
builder.Services.AddScoped<IMoodAnalyzer, MoodAnalyzer>();
var app = builder.Build();
// Configure the HTTP request pipeline
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
// Enable CORS here
app.UseCors();
app.UseHttpsRedirection();
app.UseDefaultFiles(); // enables index.html fallback
app.UseStaticFiles(); // serve from wwwroot
// Map endpoints
app.MapMoodEndpoints();
app.MapFallbackToFile("index.html");
app.Run();