Enable Electricity Api local usage
This commit is contained in:
@@ -33,6 +33,16 @@ builder.Services.AddDbContext<DatabaseContext>((DbContextOptionsBuilder builder)
|
||||
builder.UseSqlite($"Data Source={sqlite3DatabaseFilePath}");
|
||||
});
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy(
|
||||
name: "default",
|
||||
policy =>
|
||||
{
|
||||
policy.WithOrigins("http://localhost:8080");
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.AddControllers()
|
||||
.AddJsonOptions(config =>
|
||||
{
|
||||
@@ -46,8 +56,10 @@ var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseHttpsRedirection();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseCors("default");
|
||||
}
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
@@ -56,6 +56,7 @@ public class ElectricityService
|
||||
}
|
||||
|
||||
var lastAsModel = Day.FromEntity(last);
|
||||
// TODO fix UTC issues here (just return the date, don't use timestamps)
|
||||
return new Day(
|
||||
lastAsModel.DateTime,
|
||||
lastAsModel.TotalPowerUse - firstAsModel.TotalPowerUse,
|
||||
|
||||
Reference in New Issue
Block a user