feat:Initial commit

This commit is contained in:
elar1s
2025-09-25 22:21:41 +03:00
commit 02934b1fd9
35 changed files with 1267 additions and 0 deletions

63
StoreService/Program.cs Normal file
View File

@@ -0,0 +1,63 @@
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Serilog;
using StoreService.Database;
using StoreService.Middleware;
using StoreService.Repositories;
using StoreService.Services;
using StoreService.Extensions; // added for DI extension
using Newtonsoft.Json; // added
var builder = WebApplication.CreateBuilder(args);
#region Serilog
// Use new logging extension
builder.Host.AddSerilogLogging();
#endregion
#region Services
builder.Services
.AddControllers()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
options.SerializerSettings.Formatting = Formatting.None;
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFilename);
if (File.Exists(xmlPath))
{
options.IncludeXmlComments(xmlPath, includeControllerXmlComments: true);
}
});
// Granular DI registration chain
builder.Services
.AddDatabase(builder.Configuration)
.AddRepositories()
.AddDomainServices();
#endregion
var app = builder.Build();
#region Middleware
app.UseSerilogRequestLogging();
app.UseGlobalErrorHandling();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
#endregion
app.Run();