/
TOXYGENCY
/
LogTheDay
Обзор
Документация
Войти
/
TOXYGENCY
/
LogTheDay
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
LogTheDay.WebAPI/Program.cs
49 строк
2 KB
TOXYGENCY
Dockerfile.
21 ноя 2024, 22:19
21 ноя 2024, 22:19
7f5b095
Код
Авторство
О чём код?
using LogTheDay.LogTheDay.WebAPI.Domain.Interfaces; using LogTheDay.LogTheDay.WebAPI.Infrastructure; using LogTheDay.LogTheDay.WebAPI.Services; using Microsoft.EntityFrameworkCore; using Serilog; var builder = WebApplication.CreateBuilder(args); // Add services to the container. Log.Logger = new LoggerConfiguration() .MinimumLevel.Error() .WriteTo.Console(outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}") .WriteTo.File("logs/LogTheDay-.log", outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}", rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true, fileSizeLimitBytes: 10485760, // 10 MB retainedFileCountLimit: 31) .CreateLogger(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddTransient<IUsersRepository, UsersRepository>(); builder.Services.AddTransient<IPagesRepository, PagesSQLRepository>(); builder.Services.AddTransient<IUsersService, UsersService>(); // TODO: настроить подключение через переменные среды builder.Services.AddDbContext<LogTheDayContext>( options => options.UseNpgsql(builder.Configuration.GetConnectionString("MainConnectionString"))); builder.Host.UseSerilog(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); //app.MapUserEndpoints(); app.Run();