This repository was archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (33 loc) · 1.37 KB
/
Program.cs
File metadata and controls
41 lines (33 loc) · 1.37 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
using System.Net;
using ArcaeaUnlimitedAPI.Core;
using Microsoft.AspNetCore.HttpOverrides;
using Newtonsoft.Json;
using BackgroundService = ArcaeaUnlimitedAPI.Core.BackgroundService;
TaskScheduler.UnobservedTaskException += (_, eventArgs) =>
{
Logger.ExceptionError(eventArgs.Exception.InnerException!);
eventArgs.SetObserved();
};
ServicePointManager.DefaultConnectionLimit = 64;
ServicePointManager.ReusePort = true;
GlobalConfig.Init();
DatabaseManager.Init();
ArcaeaFetch.Init();
BackgroundService.Init();
ConfigWatcher.Init();
GlobalConfig.CheckUpdate();
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore)
.ConfigureApiBehaviorOptions(options =>
{
options.SuppressModelStateInvalidFilter = true;
options.SuppressMapClientErrors = true;
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddCors(options => options.AddDefaultPolicy(i => i.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()));
var app = builder.Build();
app.UseCors();
app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandler = ExceptionHandler.Invoke });
app.UseForwardedHeaders(new() { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto });
app.MapControllers();
app.Run();