Add power database support

This commit is contained in:
2019-10-15 19:41:52 -04:00
parent 5bc8018068
commit d970f80278
12 changed files with 209 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Builder;
using ChrisKaczor.HomeMonitor.Power.Service.Data;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.ResponseCompression;
@@ -12,6 +13,8 @@ namespace ChrisKaczor.HomeMonitor.Power.Service
{
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<Database>();
services.AddHostedService<PowerReader>();
services.Configure<GzipCompressionProviderOptions>(options =>
@@ -35,6 +38,9 @@ namespace ChrisKaczor.HomeMonitor.Power.Service
if (environment.IsDevelopment())
applicationBuilder.UseDeveloperExceptionPage();
var database = applicationBuilder.ApplicationServices.GetService<Database>();
database.EnsureDatabase();
applicationBuilder.UseCors("CorsPolicy");
applicationBuilder.UseResponseCompression();