This commit is contained in:
OlgunR
2026-01-16 14:10:59 +01:00
6 changed files with 12 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ using DbFirst.Infrastructure;
using DbFirst.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
//TODO: create and add exception handling middleware
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@@ -11,6 +13,7 @@ builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// TODO: allow listed origins configured in appsettings.json
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
@@ -21,9 +24,11 @@ builder.Services.AddCors(options =>
});
});
// TODO: Create extension method for this in Infrastructure layer in case of using in multiple projects
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
// TODO: Create extension method for this in Application layer in case of using in multiple projects
builder.Services.AddAutoMapper(typeof(CatalogProfile).Assembly, typeof(ApplicationDbContext).Assembly);
builder.Services.AddScoped<ICatalogRepository, CatalogRepository>();