Innovenergy_trunk/csharp/App/Backend/Program.cs

56 lines
1.2 KiB
C#

using InnovEnergy.App.Backend.Database;
using Microsoft.OpenApi.Models;
namespace InnovEnergy.App.Backend;
public static class Program
{
public static void Main(String[] args)
{
//Db.CreateFakeRelations();
Db.Init();
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", OpenApiInfo);
c.UseAllOfToExtendReferenceSchemas();
c.SupportNonNullableReferenceTypes();
});
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseCors(p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()) ;
app.UseHttpsRedirection();
app.MapControllers();
app.Run();
}
private static OpenApiInfo OpenApiInfo { get; } = new OpenApiInfo
{
Title = "InnovEnergy Backend API",
Version = "v1"
};
}
// var x = new CorsPolicy
// {
// Headers = { "*" },
// Origins = { "*" },
// Methods = { "*" }
// };