2024-12-31 18:40:08 -05:00
|
|
|
using System.Reflection;
|
|
|
|
using Microsoft.OpenApi.Models;
|
2024-12-31 01:01:16 -05:00
|
|
|
using ZenithInfo.Components;
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
// Add services to the container.
|
2024-12-31 01:03:35 -05:00
|
|
|
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
|
2024-12-31 18:40:08 -05:00
|
|
|
builder.Services.AddHttpLogging(o => { });
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
builder.Services.AddSwaggerGen(opts =>
|
|
|
|
{
|
|
|
|
opts.SwaggerDoc("v1", new OpenApiInfo { Title = "Zenith Info API", Version = "v1" });
|
|
|
|
opts.AddSecurityDefinition(
|
|
|
|
"Bearer",
|
|
|
|
new OpenApiSecurityScheme
|
|
|
|
{
|
|
|
|
Description =
|
|
|
|
"JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
|
|
|
|
Name = "Authorization",
|
|
|
|
In = ParameterLocation.Header,
|
|
|
|
Type = SecuritySchemeType.ApiKey,
|
|
|
|
Scheme = "Bearer",
|
|
|
|
}
|
|
|
|
);
|
|
|
|
opts.AddSecurityRequirement(
|
|
|
|
new OpenApiSecurityRequirement
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new OpenApiSecurityScheme
|
|
|
|
{
|
|
|
|
Reference = new OpenApiReference
|
|
|
|
{
|
|
|
|
Type = ReferenceType.SecurityScheme,
|
|
|
|
Id = "Bearer",
|
|
|
|
},
|
|
|
|
Scheme = "oauth2",
|
|
|
|
Name = "Bearer",
|
|
|
|
In = ParameterLocation.Header,
|
|
|
|
},
|
|
|
|
new List<string>()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
|
|
|
opts.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFile));
|
|
|
|
});
|
2024-12-31 01:01:16 -05:00
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
2024-12-31 18:40:08 -05:00
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
|
2024-12-31 01:01:16 -05:00
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
|
|
app.UseHsts();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseAntiforgery();
|
|
|
|
|
2024-12-31 01:03:35 -05:00
|
|
|
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
|
2024-12-31 01:01:16 -05:00
|
|
|
|
|
|
|
app.Run();
|