pet-companion-back/Program.cs
2025-01-31 23:41:30 -03:00

43 lines
1.3 KiB
C#

using Microsoft.EntityFrameworkCore;
using pet_companion_api.Data;
using pet_companion_api.Repositories;
using pet_companion_api.Services;
namespace pet_companion_api
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Configure Entity Framework Core
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(connectionString));
builder.Services.AddScoped<PetRepository>();
builder.Services.AddScoped<PetService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
}