This repository was archived by the owner on Mar 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartup.cs
More file actions
59 lines (52 loc) · 1.5 KB
/
Copy pathStartup.cs
File metadata and controls
59 lines (52 loc) · 1.5 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
using SparkStatsAPI.Services;
using SparkStatsAPI.Utils;
using SpotifyAPI.Web;
using SpotifyAPI.Web.Http;
namespace SparkStatsAPI
{
public class Startup(IConfiguration configuration)
{
public IConfiguration Configuration { get; } = configuration;
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins(
Environment.GetEnvironmentVariable("FRONTEND_URL")!)
.AllowAnyHeader()
.AllowAnyMethod();
});
});
services.AddSingleton(
SpotifyClientConfig
.CreateDefault()
.WithHTTPLogger(new SimpleConsoleHTTPLogger())
);
services.AddScoped<SpotifyClientBuilder>();
services.AddScoped<ArtistService>();
services.AddScoped<AuthService>();
services.AddScoped<GenreService>();
services.AddScoped<PlaylistService>();
services.AddScoped<TrackService>();
services.AddScoped<UserService>();
services.AddControllers();
services.AddEndpointsApiExplorer();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseCors();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}