42 lines
977 B
C#
42 lines
977 B
C#
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using public_valetax.Data;
|
||
|
|
using public_valetax.Repositories;
|
||
|
|
using public_valetax.Middleware;
|
||
|
|
using Scalar.AspNetCore;
|
||
|
|
|
||
|
|
var builder = WebApplication.CreateBuilder(args);
|
||
|
|
|
||
|
|
// Add services to the container.
|
||
|
|
builder.Services.AddOpenApi();
|
||
|
|
|
||
|
|
// Add Entity Framework
|
||
|
|
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
||
|
|
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
|
||
|
|
|
||
|
|
// Add repositories
|
||
|
|
builder.Services.AddScoped<ITreeRepository, TreeRepository>();
|
||
|
|
builder.Services.AddScoped<IJournalRepository, JournalRepository>();
|
||
|
|
|
||
|
|
// Add controllers
|
||
|
|
builder.Services.AddControllers();
|
||
|
|
|
||
|
|
var app = builder.Build();
|
||
|
|
|
||
|
|
// Configure the HTTP request pipeline.
|
||
|
|
if (app.Environment.IsDevelopment())
|
||
|
|
{
|
||
|
|
app.MapOpenApi();
|
||
|
|
app.MapScalarApiReference();
|
||
|
|
}
|
||
|
|
|
||
|
|
app.UseHttpsRedirection();
|
||
|
|
|
||
|
|
// Add exception handling middleware
|
||
|
|
app.UseExceptionHandling();
|
||
|
|
|
||
|
|
app.UseAuthorization();
|
||
|
|
|
||
|
|
app.MapControllers();
|
||
|
|
|
||
|
|
app.Run();
|