-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
37 lines (26 loc) · 922 Bytes
/
Program.cs
File metadata and controls
37 lines (26 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Scalar.AspNetCore;
using Microsoft.EntityFrameworkCore;
using API.Data;
using API.Services; // Adicione este namespace para o serviço de cotação
var builder = WebApplication.CreateBuilder(args);
// --- CONFIGURAÇÃO DOS SERVIÇOS (BUILDER) ---
builder.Services.AddControllers();
builder.Services.AddOpenApi();
// Configura o banco de dados SQLite
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlite("Data Source=moedas.db"));
// REGISTRA O SERVIÇO DE PREÇOS REAIS
builder.Services.AddHttpClient<CoinService>();
var app = builder.Build();
// --- CONFIGURAÇÃO DO PIPELINE (APP) ---
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.MapScalarApiReference();
}
// Redireciona a raiz para o Scalar facilitar sua vida
app.MapGet("/", () => Results.Redirect("/scalar/v1"));
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();