Backend of DumbYT, a small c# web api. http://dumbyt.hak8or.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7 KiB

using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Hangfire;
using Hangfire.PostgreSql;
using Microsoft.EntityFrameworkCore;
namespace YTManager {
public class Startup {
public Startup(IConfiguration configuration) {
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public static string DBStr {
get {
string s = Environment.GetEnvironmentVariable("POSTGRESQL_DBSTR");
s = s ?? "Server=localhost;Port=32768;Database=DumbYT;User Id=DumbYT;Password=DumbYTPassword;";
return s;
}
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) {
Console.WriteLine("Using db string of: " + DBStr);
services.AddMvc();
services.AddDbContext<MediaDB>(x => x.UseNpgsql(DBStr));
services.AddHangfire(x => x.UsePostgreSqlStorage(DBStr));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseCors(b => { b.AllowAnyOrigin(); b.AllowAnyMethod(); });
app.UseMvc();
app.UseHangfireServer();
app.UseHangfireDashboard();
}
}
}