0
0
RhSolutions-Api/RhSolutions.Api/Program.cs

41 lines
1.1 KiB
C#
Raw Permalink Normal View History

2022-12-14 09:53:10 +03:00
using Microsoft.EntityFrameworkCore;
2023-05-11 07:55:26 +03:00
using RhSolutions.Models;
2022-12-14 09:53:10 +03:00
using RhSolutions.Api.Services;
2023-09-19 14:56:55 +03:00
using RhSolutions.Api.Middleware;
2023-10-10 22:26:16 +03:00
using RhSolutions.QueryModifiers;
2022-12-14 09:53:10 +03:00
2023-10-30 21:49:58 +03:00
var builder = WebApplication.CreateBuilder();
2022-12-14 09:53:10 +03:00
string dbHost = builder.Configuration["DB_HOST"],
dbPort = builder.Configuration["DB_PORT"],
dbName = builder.Configuration["DB_DATABASE"],
dbUser = builder.Configuration["DB_USER"],
dbPassword = builder.Configuration["DB_PASSWORD"];
string connectionString = builder.Configuration["ConnectionsStrings:RhSolutionsLocal"]
?? $"Host={dbHost};Port={dbPort};Database={dbName};Username={dbUser};Password={dbPassword}";
builder.Services.AddDbContext<RhSolutionsContext>(opts =>
{
opts.UseNpgsql(connectionString);
if (builder.Environment.IsDevelopment())
{
opts.EnableSensitiveDataLogging(true);
}
});
2023-10-30 21:49:58 +03:00
2023-09-19 14:56:55 +03:00
builder.Services.AddScoped<IPricelistParser, ClosedXMLParser>()
.AddScoped<IProductTypePredicter, ProductTypePredicter>()
2023-10-30 21:49:58 +03:00
.AddSingleton<ProductQueryModifierFactory>()
.AddGrpc();
2022-12-14 09:53:10 +03:00
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
2023-10-30 21:49:58 +03:00
app.MapGrpcService<SearchService>();
2023-09-19 14:56:55 +03:00
app.UseMiddleware<QueryModifier>();
2022-12-14 09:53:10 +03:00
app.Run();