-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (32 loc) · 1.26 KB
/
Program.cs
File metadata and controls
39 lines (32 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Threading.Channels;
using be.Components;
using be.Data;
using be.Endpoints;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
var channel = Channel.CreateUnbounded<GameEvent>();
builder.Services.AddSingleton(channel.Reader);
builder.Services.AddDbContextFactory<BeDataContext>(options => options.UseNpgsql(builder.Configuration.GetConnectionString("BeDataContext")));
builder.Services.AddRazorComponents();
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
options.Cookie.Name = "becookie";
options.ExpireTimeSpan = new TimeSpan(10000, 1, 1, 1);
});
builder.Services.AddAuthorization();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
}
app.UseStaticFiles();
app.UseAntiforgery();
app.UseAuthentication();
app.UseAuthorization();
app.MapRazorComponents<App>();
app.MapPost("user/create", User.Create);
app.MapGet("game/events", Game.Events);
app.Run();