2025-01-11 23:30:12 +00:00
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2025-01-11 21:29:43 +00:00
|
|
|
using Scalar.AspNetCore;
|
2025-01-11 23:30:12 +00:00
|
|
|
using Trazo.Model;
|
2025-01-11 21:29:43 +00:00
|
|
|
|
2025-01-11 21:20:05 +00:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
2025-01-11 23:30:12 +00:00
|
|
|
builder.Services.AddControllers();
|
|
|
|
|
2025-01-11 21:20:05 +00:00
|
|
|
// Add services to the container.
|
2025-01-11 23:30:12 +00:00
|
|
|
builder.Services.AddAuthorization();
|
|
|
|
builder.Services.AddAuthentication().AddCookie(IdentityConstants.ApplicationScheme);
|
|
|
|
|
|
|
|
builder.Services.AddIdentityCore<User>()
|
|
|
|
.AddEntityFrameworkStores<ApplicationDbContext>()
|
|
|
|
.AddApiEndpoints();
|
|
|
|
|
|
|
|
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
|
|
|
options.UseNpgsql(builder.Configuration.GetConnectionString("Database")));
|
2025-01-11 21:20:05 +00:00
|
|
|
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
2025-01-12 21:09:25 +00:00
|
|
|
builder.Services.AddSwaggerGen(options =>
|
|
|
|
{
|
|
|
|
options.SupportNonNullableReferenceTypes();
|
|
|
|
}
|
|
|
|
);
|
2025-01-11 21:20:05 +00:00
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
{
|
2025-01-11 21:29:43 +00:00
|
|
|
app.UseSwagger(options =>
|
|
|
|
{
|
|
|
|
options.RouteTemplate = "openapi/{documentName}.json";
|
|
|
|
});
|
|
|
|
app.MapScalarApiReference();
|
2025-01-11 21:20:05 +00:00
|
|
|
}
|
|
|
|
|
2025-01-11 23:30:12 +00:00
|
|
|
|
|
|
|
app.MapIdentityApi<User>();
|
|
|
|
|
2025-01-11 21:20:05 +00:00
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
app.Run();
|