2023-01-25 08:48:50 -05:00
|
|
|
using BinaryDad.Notes;
|
2023-01-05 10:32:21 -05:00
|
|
|
using BinaryDad.Notes.Services;
|
2023-05-10 16:22:51 -04:00
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
2023-01-05 10:32:21 -05:00
|
|
|
|
2022-11-29 10:14:15 -05:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
2023-08-29 20:26:04 -04:00
|
|
|
builder.Configuration.AddEnvironmentVariables();
|
|
|
|
|
2022-11-29 10:14:15 -05:00
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllersWithViews();
|
2023-01-25 08:48:50 -05:00
|
|
|
builder.Services.AddSignalR();
|
2023-01-05 10:32:21 -05:00
|
|
|
builder.Services.AddSingleton<INoteService, FileNoteService>();
|
2022-11-29 10:14:15 -05:00
|
|
|
|
2023-05-10 16:22:51 -04:00
|
|
|
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(o =>
|
|
|
|
{
|
|
|
|
o.LoginPath = "/login";
|
2023-06-21 10:49:13 -04:00
|
|
|
o.Cookie.Name = "NotesUser";
|
|
|
|
o.Cookie.MaxAge = TimeSpan.FromDays(3);
|
2023-07-28 14:46:06 -04:00
|
|
|
o.SlidingExpiration = true;
|
2023-05-10 16:22:51 -04:00
|
|
|
});
|
|
|
|
|
2022-11-29 10:14:15 -05:00
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
|
|
{
|
2023-01-09 16:56:30 -05:00
|
|
|
app.UseHttpsRedirection();
|
2022-11-29 10:14:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
|
|
app.UseRouting();
|
2023-05-10 16:22:51 -04:00
|
|
|
app.UseAuthentication();
|
2022-11-29 10:14:15 -05:00
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllerRoute(
|
|
|
|
name: "default",
|
2023-05-10 16:22:51 -04:00
|
|
|
pattern: "{controller=Note}/{action=Index}/{id?}");
|
2022-11-29 10:14:15 -05:00
|
|
|
|
2023-01-25 08:48:50 -05:00
|
|
|
app.MapHub<NoteHub>("/noteHub");
|
|
|
|
|
2022-11-29 10:14:15 -05:00
|
|
|
app.Run();
|