Notes/Program.cs
2023-08-29 20:26:04 -04:00

43 lines
1007 B
C#

using BinaryDad.Notes;
using BinaryDad.Notes.Services;
using Microsoft.AspNetCore.Authentication.Cookies;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddEnvironmentVariables();
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddSignalR();
builder.Services.AddSingleton<INoteService, FileNoteService>();
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(o =>
{
o.LoginPath = "/login";
o.Cookie.Name = "NotesUser";
o.Cookie.MaxAge = TimeSpan.FromDays(3);
o.SlidingExpiration = true;
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseHttpsRedirection();
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Note}/{action=Index}/{id?}");
app.MapHub<NoteHub>("/noteHub");
app.Run();