40 lines
1,013 B
C#
40 lines
1,013 B
C#
using System.Reflection;
|
|
using FluentValidation;
|
|
using Mizuki.Database;
|
|
using Mizuki.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddRazorPages();
|
|
builder.Services.AddControllers();
|
|
|
|
builder.Services.AddValidatorsFromAssembly(
|
|
Assembly.GetCallingAssembly());
|
|
|
|
builder.Services.AddScoped<DriveService>();
|
|
builder.Services.AddScoped<LoginService>();
|
|
builder.Services.AddScoped<UploadService>();
|
|
builder.Services.AddScoped<UserService>();
|
|
builder.Services.AddDbContext<MizukiDbContext>();
|
|
builder.Services.AddHttpContextAccessor();
|
|
builder.Services.AddAuthentication("MizukiAuth")
|
|
.AddCookie("MizukiAuth", options =>
|
|
{
|
|
options.LoginPath = "/login";
|
|
options.LogoutPath = "/api/user/logout";
|
|
options.AccessDeniedPath = "/";
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MapControllers();
|
|
app.MapFallbackToFile("index.html");
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.MapRazorPages();
|
|
app.MapControllers();
|
|
|
|
app.Run();
|