using AZKiServer.Models; using AZKiServer.Services; using MongoDB.Driver; var builder = WebApplication.CreateBuilder(args); var config = builder.Configuration; var dbString = config["DB_STRING"]; var dbClient = new MongoClient(dbString); var db = dbClient.GetDatabase("AZKi"); // Add services to the container. builder.Services.AddSingleton(dbClient); builder.Services.AddSingleton(db); builder.Services.AddGrpc(); builder.Services.AddControllers(opt => opt.ModelBinderProviders.Add(new BsonIdModelBinderProvider())); builder.Services.AddHostedService(); builder.Services.AddTransient(); builder.Services.AddCors(o => { o.AddPolicy("AllowAll", p => { p.AllowAnyOrigin(); p.AllowAnyMethod(); p.AllowAnyHeader(); }); o.AddPolicy("RPC", p => { p.AllowAnyMethod(); p.AllowAnyHeader(); p.WithExposedHeaders("Grpc-Status", "Grpc-Message", "Grpc-Encoding", "Grpc-Accept-Encoding"); p.AllowAnyOrigin(); }); }); var app = builder.Build(); // Configure the HTTP request pipeline. //app.MapGrpcService(); app.MapFallbackToFile("index.html"); app.Run();