-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (47 loc) · 1.75 KB
/
Program.cs
File metadata and controls
55 lines (47 loc) · 1.75 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
using Microsoft.EntityFrameworkCore;
using Yota_backend.ApplicationDbContext;
using Yota_backend.ApplicationDbContext.Interface;
using Yota_backend.Mapper;
using Yota_backend.Services;
using Yota_backend.Services.Interface;
var builder = WebApplication.CreateBuilder(args);
ConfigureServices(builder);
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseCors("AllowAllOrigins");
app.MapControllers();
app.UseAuthorization();
app.Run();
return;
//***********************************************************************************************//
static void ConfigureServices(WebApplicationBuilder builder)
{
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var dbString = builder.Configuration.GetConnectionString("Psql");
builder.Services.AddDbContext<AppDbContext>(options => options.UseNpgsql(dbString));
builder.Services.AddScoped<IAppDbContext, AppDbContext>();
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAllOrigins",
builder =>
{
builder.AllowAnyOrigin();
builder.AllowAnyMethod()
.AllowAnyHeader();
});
});
builder.Services.AddAutoMapper(typeof(MapProfile));
builder.Services.AddScoped<IPlaylistService, PlaylistService>();
builder.Services.AddScoped<IAlbumService, AlbumService>();
builder.Services.AddScoped<IArtistService, ArtistService>();
builder.Services.AddScoped<IGenreService, GenreService>();
builder.Services.AddScoped<ITrackService, TrackService>();
builder.Services.AddScoped<ICryptographyService, CryptographyService>();
}