-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
102 lines (84 loc) · 3.42 KB
/
Program.cs
File metadata and controls
102 lines (84 loc) · 3.42 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// . @@ _____ _______ _ _ _____ _____ ____
// @ @@@@@ / ____|__ __| | | | __ \_ _/ __ \
// @@@ @@@@ | (___ | | | | | | | | || || | | |
// @@@@@@@@@ @ @ \___ \ | | | | | | | | || || | | |
// @@@@ @@@@@@@ ____) | | | | |__| | |__| || || |__| |
// @@@@@ @@@ |_____/ |_| \____/|_____/_____\____/
// @@@ @@@@@@@ @@ __ ___
// @@ @@@@ @@ @@ / \ |\ | | | |\ | |__
// @@ @@@ @@ @ @ \__/ | \| |___ | | \| |___
// @@@@ @@@ @@@@ @@@@
// @@@@ @@@@@ @@@@@@@ https://github.com/UnlostWorld/StudioOnline
// @@@
// @@@@@@@@@@@@@@ This software is licensed under the
// @@@@ @ GNU AFFERO GENERAL PUBLIC LICENSE v3
namespace StudioOnline;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StudioOnline.DiscordBot;
using Microsoft.Extensions.Configuration;
using StudioOnline.Identity;
using StudioOnline.Analytics;
using StudioOnline.Repository;
using StudioOnline.Utilities;
using StudioOnline.Sync;
using Microsoft.AspNetCore.HttpOverrides;
public class Program
{
public static void Main(string[] args)
{
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
services.AddRazorPages();
services.AddControllers();
services.AddOutputCache(options =>
{
options.AddBasePolicy(builder => builder.Cache());
options.AddBasePolicy(builder => builder.Tag("all"));
});
services.AddSingleton<IAnalyticsService, AnalyticsService>();
services.AddSingleton<ISyncService, SyncService>();
services.AddDiscordBot(options =>
{
options.SetConnectionString(builder.Configuration.GetConnectionString("DiscordBot"));
options.AddInteractionModule<EchoCommandModule>();
options.AddInteractionModule<ErrorCommandModule>();
options.AddInteractionModule<RepositoryCommandModule>();
options.AddInteractionModule<ManagementCommandModule>();
});
services.AddStudioIdentity(options =>
{
options.IdentityConnectionString = builder.Configuration.GetConnectionString("Identity");
options.DiscordClientId = builder.Configuration["StudioOnline_DiscordClientId"];
options.DiscordClientSecret = builder.Configuration["StudioOnline_DiscordClientSecret"];
});
services.AddPluginRepository(options =>
{
options.SetConnectionString(builder.Configuration.GetConnectionString("PluginRepository"));
});
WebApplication app = builder.Build();
// Force HTTPS in production
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.RouteSubdomain("marketplace", "/Marketplace");
app.UseOutputCache();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapStaticAssets();
app.MapRazorPages().WithStaticAssets();
app.UseStaticFiles();
app.MapControllerRoute("default", "api/{controller=Home}/{action=Index}");
app.MapControllers();
app.UseDiscordBot();
app.UseStudioIdentity();
ForwardedHeadersOptions forwardedHeaders = new();
forwardedHeaders.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
app.UseForwardedHeaders(forwardedHeaders);
app.Run();
}
}