ef15fd6247
Full backend implementation: - Multi-tenant cafe/restaurant management (menus, orders, tables, staff) - POS order flow with ZarinPal and Snappfood payment integration - OTP authentication via Kavenegar SMS - QR digital menu with public discover/finder endpoints - Customer loyalty, coupons, CRM - PostgreSQL via EF Core, Redis for caching/sessions - Background jobs, webhook handlers - Full migration history Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Meezi.API.Extensions;
|
|
using Meezi.Infrastructure.Data;
|
|
using Serilog;
|
|
|
|
namespace Meezi.API;
|
|
|
|
public partial class Program
|
|
{
|
|
public static async Task Main(string[] args)
|
|
{
|
|
Log.Logger = new LoggerConfiguration()
|
|
.WriteTo.Console()
|
|
.CreateLogger();
|
|
|
|
var hostAborted = false;
|
|
try
|
|
{
|
|
var app = BuildWebApplication(args);
|
|
|
|
if (app.Configuration.GetValue<bool>("RUN_MIGRATIONS"))
|
|
{
|
|
await using var scope = app.Services.CreateAsyncScope();
|
|
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
|
await db.Database.MigrateAsync();
|
|
await DatabaseSchemaPatches.ApplyAsync(db);
|
|
}
|
|
|
|
await PlatformDataSeeder.EnsureCatalogUpgradesAsync(app.Services);
|
|
|
|
if (!app.Configuration.GetValue<bool>("Testing:SkipSeed"))
|
|
{
|
|
await DevelopmentDataSeeder.SeedAsync(app.Services);
|
|
await PlatformDataSeeder.SeedAsync(app.Services);
|
|
}
|
|
|
|
await app.RunAsync();
|
|
}
|
|
catch (HostAbortedException)
|
|
{
|
|
hostAborted = true;
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "Application terminated unexpectedly");
|
|
}
|
|
finally
|
|
{
|
|
if (!hostAborted)
|
|
await Log.CloseAndFlushAsync();
|
|
}
|
|
}
|
|
|
|
public static WebApplication BuildWebApplication(
|
|
string[] args,
|
|
Action<WebApplicationBuilder>? configureBeforeServices = null,
|
|
Action<WebApplicationBuilder>? configureAfterServices = null)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
configureBeforeServices?.Invoke(builder);
|
|
|
|
builder.Host.UseSerilog((context, services, configuration) => configuration
|
|
.ReadFrom.Configuration(context.Configuration)
|
|
.ReadFrom.Services(services)
|
|
.Enrich.FromLogContext()
|
|
.WriteTo.Console());
|
|
|
|
builder.Services.AddMeeziServices(builder.Configuration);
|
|
configureAfterServices?.Invoke(builder);
|
|
|
|
var app = builder.Build();
|
|
app.ConfigureMeeziPipeline();
|
|
return app;
|
|
}
|
|
}
|