40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using HackerNet.Infrastructure.AspNet;
|
|
using HackerNet.Infrastructure.Repositories.EntityFramework;
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddHackerNetServicesEntityFramework(builder.Configuration);
|
|
builder.Services.AddControllers();
|
|
builder.Services
|
|
.AddIdentityCore<IdentityUser>()
|
|
.AddRoles<IdentityRole>()
|
|
.AddSignInManager()
|
|
.AddEntityFrameworkStores<HackerContext>();
|
|
|
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
.AddJwtBearer();
|
|
|
|
builder.Services.AddOpenApiDocument(d =>
|
|
{
|
|
d.Title = "HackerNet API";
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MigrateDatabase();
|
|
|
|
app.UseOpenApi();
|
|
app.UseSwaggerUi3();
|
|
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.MapGet("/", () => "Hello World!");
|
|
app.MapControllers();
|
|
|
|
app.Run();
|