Main 작업을 수행합니다.
35 {
36 HostApplicationBuilder builder = Host.CreateApplicationBuilder();
37 builder.Configuration.AddUserSecrets("codemaru-oauth-2ba4e1b2");
38
39 int serverPort = GetInt(builder.Configuration, "FamilyServer:Port", 5080);
40 bool listenAnyIp = GetBool(builder.Configuration, "FamilyServer:ListenAnyIp", true);
41 AuthOptions authOptions =
42 builder.Configuration.GetSection(AuthOptions.SectionName).Get<AuthOptions>() ?? new AuthOptions();
43 string usersDbPath = ResolvePath(
44 builder.Configuration[$"{AuthOptions.SectionName}:UsersDbPath"],
45 Path.Combine(AppContext.BaseDirectory, "App_Data", "codemaru.db"));
46
47 builder.Services.AddDreamineHybridWpf();
48 builder.Services.AddDreamineIdentityWpfHost();
49
50 var familyOpts = FamilyOptions.From(builder.Configuration);
51 builder.Services.AddSingleton(familyOpts);
52 builder.Services.AddSingleton<IFamilyTenantStore, JsonFamilyTenantStore>();
53 builder.Services.AddSingleton<IPostStore, JsonPostStore>();
54 builder.Services.AddSingleton<IAlbumStore, JsonAlbumStore>();
55 builder.Services.AddSingleton<IGlobalSettingsStore, JsonGlobalSettingsStore>();
56 builder.Services.AddSingleton<IMediaService, LocalMediaService>();
57 builder.Services.AddSingleton<IReactionStore, JsonReactionStore>();
58
59 builder.Services.AddSingleton<Views.MainWindow>();
60 builder.Services.AddHostedService<GhostAccountCleanupService>();
61
62 builder.Services.AddDreamineBlazorServer<AppShell>(options =>
63 {
64 options.Port = serverPort;
65 options.ListenAnyIp = listenAnyIp;
66 options.SharedServiceTypes.Add(typeof(FamilyOptions));
67 options.SharedServiceTypes.Add(typeof(IFamilyTenantStore));
68 options.SharedServiceTypes.Add(typeof(IPostStore));
69 options.SharedServiceTypes.Add(typeof(IAlbumStore));
70 options.SharedServiceTypes.Add(typeof(IGlobalSettingsStore));
71 options.SharedServiceTypes.Add(typeof(IMediaService));
72 options.SharedServiceTypes.Add(typeof(IReactionStore));
73 options.AddPhysicalStaticFiles(familyOpts.ResolvedDataPath, "/family-data");
74
75
76
77
78
79 options.ConfigureServices = services =>
80 {
81 services.AddServerSideBlazor().AddHubOptions(o =>
82 {
83 o.MaximumReceiveMessageSize = null;
84 o.ClientTimeoutInterval = TimeSpan.FromMinutes(10);
85 o.HandshakeTimeout = TimeSpan.FromMinutes(2);
86 o.KeepAliveInterval = TimeSpan.FromSeconds(10);
87 });
88
89 services.AddAntiforgery(o =>
90 {
91 o.Cookie.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Lax;
92 o.Cookie.SecurePolicy = Microsoft.AspNetCore.Http.CookieSecurePolicy.SameAsRequest;
93 });
94
95 services.Configure<CircuitOptions>(o =>
96 {
97 o.DisconnectedCircuitMaxRetained = 100;
98 o.DisconnectedCircuitRetentionPeriod = TimeSpan.FromMinutes(3);
99 o.JSInteropDefaultCallTimeout = TimeSpan.FromMinutes(1);
100 o.MaxBufferedUnacknowledgedRenderBatches = 10;
101 });
102
103 services.AddScoped<FamilyUserContext>();
104 };
105
106 options.AddDreamineIdentity(authOptions, usersDbPath);
107 });
108
109
110 var wwwroot = Path.Combine(AppContext.BaseDirectory, "wwwroot");
111 try { OgImageGenerator.EnsureGenerated(wwwroot); } catch { }
112
113 builder.Build().RunDreamineWpfApp<App>();
114 }