Added backend functionality

This commit is contained in:
2025-03-01 16:57:18 +01:00
parent 55be2f1e88
commit a1ba2f9571
19 changed files with 427 additions and 11 deletions

View File

@@ -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();