2017-03-18 23:52:44 +01:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2017-04-26 20:29:25 +02:00
|
|
|
|
using Bit.Core;
|
2017-04-26 22:13:24 +02:00
|
|
|
|
using Stripe;
|
2017-05-06 02:57:33 +02:00
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
using Serilog.Events;
|
2017-03-18 23:52:44 +01:00
|
|
|
|
|
|
|
|
|
namespace Bit.Billing
|
|
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
public Startup(IHostingEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
var builder = new ConfigurationBuilder()
|
2017-05-06 03:49:55 +02:00
|
|
|
|
.AddSettingsConfiguration<Startup>(env);
|
2017-03-18 23:52:44 +01:00
|
|
|
|
Configuration = builder.Build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConfigurationRoot Configuration { get; }
|
|
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
2017-04-26 20:29:25 +02:00
|
|
|
|
// Options
|
|
|
|
|
services.AddOptions();
|
|
|
|
|
|
|
|
|
|
// Settings
|
2017-05-06 02:57:33 +02:00
|
|
|
|
var globalSettings = services.AddGlobalSettingsServices(Configuration);
|
2017-04-26 20:29:25 +02:00
|
|
|
|
|
2017-04-26 22:13:24 +02:00
|
|
|
|
// Stripe Billing
|
|
|
|
|
StripeConfiguration.SetApiKey(globalSettings.StripeApiKey);
|
|
|
|
|
|
|
|
|
|
// Repositories
|
|
|
|
|
services.AddSqlServerRepositories();
|
|
|
|
|
|
2017-04-27 14:17:04 +02:00
|
|
|
|
// Context
|
|
|
|
|
services.AddScoped<CurrentContext>();
|
|
|
|
|
|
2017-04-26 22:13:24 +02:00
|
|
|
|
// Services
|
|
|
|
|
services.AddBaseServices();
|
|
|
|
|
services.AddDefaultServices();
|
|
|
|
|
|
|
|
|
|
// Mvc
|
2017-03-18 23:52:44 +01:00
|
|
|
|
services.AddMvc();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-06 02:57:33 +02:00
|
|
|
|
public void Configure(
|
|
|
|
|
IApplicationBuilder app,
|
|
|
|
|
IHostingEnvironment env,
|
|
|
|
|
IApplicationLifetime appLifetime,
|
|
|
|
|
GlobalSettings globalSettings,
|
|
|
|
|
ILoggerFactory loggerFactory)
|
2017-03-18 23:52:44 +01:00
|
|
|
|
{
|
2017-05-06 02:57:33 +02:00
|
|
|
|
loggerFactory
|
|
|
|
|
.AddSerilog(env, appLifetime, globalSettings, (e) => e.Level >= LogEventLevel.Error)
|
|
|
|
|
.AddConsole()
|
|
|
|
|
.AddDebug();
|
2017-03-18 23:52:44 +01:00
|
|
|
|
|
|
|
|
|
app.UseMvc();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|