Added backend functionality
This commit is contained in:
@@ -1,15 +1,35 @@
|
||||
using Scalar.AspNetCore;
|
||||
using WorkTime.Api;
|
||||
using WorkTime.Api.Services;
|
||||
using WorkTime.Api.Services.Implementation;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
builder.AddServiceDefaults();
|
||||
builder.Services.AddControllers();
|
||||
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddNpgsql<DatabaseContext>(builder.Configuration.GetConnectionString("data"));
|
||||
builder.Services.AddScoped<ITimeEntryService, TimeEntryService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment()) {
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference(options => {
|
||||
options.Servers = [];
|
||||
});
|
||||
|
||||
await app.Services
|
||||
.CreateAsyncScope().ServiceProvider
|
||||
.GetRequiredService<DatabaseContext>()
|
||||
.Database.EnsureCreatedAsync();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.MapControllers();
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user