-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
56 lines (44 loc) · 1.6 KB
/
Copy pathProgram.cs
File metadata and controls
56 lines (44 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using EpycusApp.Datos;
using EpycusApp.Datos.Semilla;
using EpycusApp.Middleware;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
var app = Program.CreateApp(args);
using (var scope = app.Services.CreateScope())
{
var contexto = scope.ServiceProvider.GetRequiredService<ContextoAplicacion>();
var proveedorDb = app.Configuration["Database:Provider"];
if (proveedorDb == "InMemory")
await contexto.Database.EnsureCreatedAsync();
else
await contexto.Database.MigrateAsync();
await DatosSemilla.InicializarAsync(contexto);
}
app.Run();
public partial class Program
{
public static WebApplication CreateApp(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.ConfigurarBaseDeDatos();
builder.ConfigurarAutenticacion();
builder.Services.Configure<ApiBehaviorOptions>(options =>
{
options.SuppressModelStateInvalidFilter = true;
});
builder.Services.AddControllersWithViews(options =>
{
options.Filters.Add<CargarPersonajeFilter>();
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
}).AddJsonOptions(opts =>
{
opts.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
opts.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
});
builder.ConfigurarRateLimiting();
builder.ConfigurarServiciosAplicacion();
var app = builder.Build();
app.ConfigurarMiddleware();
return app;
}
}