Finished adding user support and ability to update specific novels or set your last read chapter

This commit is contained in:
2022-07-17 20:34:06 -04:00
parent e4529e11c0
commit b5c4146d4d
34 changed files with 589 additions and 59 deletions

View File

@@ -2,8 +2,11 @@ using DBConnection;
using DBConnection.Contexts;
using DBConnection.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Treestar.Shared.Authentication.JwtBearer;
using WebNovelPortalAPI.Extensions;
using WebNovelPortalAPI.Middleware;
using WebNovelPortalAPI.Scrapers;
var builder = WebApplication.CreateBuilder(args);
@@ -11,13 +14,40 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddDbServices(builder.Configuration);
builder.Services.AddScrapers();
builder.Services.AddJwtBearerAuth(builder.Configuration);
builder.Services.AddScoped<EnsureUserCreatedMiddleware>();
builder.Services.AddControllers().AddNewtonsoftJson(opt =>
{
opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(opt =>
{
opt.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Description = "Bearer token",
Name = "Authorization",
Type = SecuritySchemeType.Http,
BearerFormat = "JWT",
Scheme = "bearer"
});
opt.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type=ReferenceType.SecurityScheme,
Id="Bearer"
}
},
new string[]{}
}
});
});
var app = builder.Build();
app.UpdateDatabase<AppDbContext>();
@@ -30,8 +60,9 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();
app.UseMiddleware<EnsureUserCreatedMiddleware>();
app.MapControllers();
app.Run();