2020-01-09 00:04:57 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Text.Json;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Alphaleonis.Win32.Filesystem;
|
|
|
|
using GraphiQl;
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.HttpsPolicy;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
2020-01-16 05:06:25 +00:00
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Http.Features;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Authorization;
|
2020-01-09 00:04:57 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Swashbuckle.AspNetCore.Swagger;
|
|
|
|
using Wabbajack.BuildServer.Controllers;
|
|
|
|
using Wabbajack.BuildServer.Models;
|
|
|
|
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;
|
2020-01-10 02:06:11 +00:00
|
|
|
using Wabbajack.BuildServer.Controllers;
|
2020-01-09 00:04:57 +00:00
|
|
|
using Microsoft.Extensions.FileProviders;
|
|
|
|
using Directory = System.IO.Directory;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.BuildServer
|
|
|
|
{
|
|
|
|
public class Startup
|
|
|
|
{
|
|
|
|
public Startup(IConfiguration configuration)
|
|
|
|
{
|
|
|
|
Configuration = configuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
{
|
|
|
|
services.AddSwaggerGen(c =>
|
|
|
|
{
|
|
|
|
c.SwaggerDoc("v1", new OpenApiInfo {Title = "Wabbajack Build API", Version = "v1"});
|
|
|
|
});
|
2020-01-16 05:06:25 +00:00
|
|
|
|
|
|
|
services.AddAuthentication(options =>
|
|
|
|
{
|
|
|
|
options.DefaultAuthenticateScheme = ApiKeyAuthenticationOptions.DefaultScheme;
|
|
|
|
options.DefaultChallengeScheme = ApiKeyAuthenticationOptions.DefaultScheme;
|
|
|
|
})
|
|
|
|
.AddApiKeySupport(options => {});
|
|
|
|
|
|
|
|
services.Configure<FormOptions>(x =>
|
|
|
|
{
|
|
|
|
x.ValueLengthLimit = int.MaxValue;
|
|
|
|
x.MultipartBodyLengthLimit = int.MaxValue;
|
|
|
|
});
|
2020-01-10 02:06:11 +00:00
|
|
|
|
2020-01-09 00:04:57 +00:00
|
|
|
services.AddSingleton<DBContext>();
|
2020-01-09 04:42:25 +00:00
|
|
|
services.AddSingleton<JobManager>();
|
|
|
|
services.AddSingleton<AppSettings>();
|
2020-01-10 02:06:11 +00:00
|
|
|
services.AddMvc();
|
|
|
|
services.AddControllers()
|
|
|
|
.AddNewtonsoftJson(o =>
|
2020-01-09 00:04:57 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
|
|
|
});
|
2020-01-09 04:42:25 +00:00
|
|
|
|
|
|
|
|
2020-01-09 00:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
|
{
|
|
|
|
SerializerSettings.Init();
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
}
|
|
|
|
|
2020-01-18 22:09:32 +00:00
|
|
|
app.UseHttpsRedirection();
|
2020-01-09 00:04:57 +00:00
|
|
|
app.UseGraphiQl();
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
app.UseStaticFiles();
|
2020-01-09 23:34:02 +00:00
|
|
|
//app.UseHttpsRedirection();
|
2020-01-09 00:04:57 +00:00
|
|
|
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
{
|
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Wabbajack Build API");
|
|
|
|
c.RoutePrefix = string.Empty;
|
|
|
|
});
|
|
|
|
app.UseRouting();
|
|
|
|
|
2020-01-09 04:42:25 +00:00
|
|
|
app.UseJobManager();
|
2020-01-09 00:04:57 +00:00
|
|
|
app.UseAuthentication();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseFileServer(new FileServerOptions
|
|
|
|
{
|
|
|
|
FileProvider = new PhysicalFileProvider(
|
|
|
|
Path.Combine(Directory.GetCurrentDirectory(), "public"))
|
|
|
|
});
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
{
|
|
|
|
endpoints.MapControllers();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|