- GeradoresService: cada tipo passa a ser um IGenerator (NIF, NIPC, NISS, CC, passaporte, IBAN, NIB, cartões, referência MB, pessoa, telefone, código postal, email, matrícula, EAN, UUID) registado em GeneratorRegistry; remove DAL/EF - GeradoresWS: minimal APIs em /api/v1 com OpenAPI + Scalar e health check - UnitTest: testes de ida e volta, valores conhecidos, detecção e API - geradoresfe: UI construída a partir dos metadados da API, validador livre, exportação CSV/JSON/TXT, nginx com API_UPSTREAM configurável - Docker, docker-compose e Jenkinsfile actualizados Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using GeradoresService;
|
|
using GeradoresWS;
|
|
using Scalar.AspNetCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddSingleton<GeneratorRegistry>();
|
|
builder.Services.AddProblemDetails();
|
|
builder.Services.AddHealthChecks();
|
|
builder.Services.AddOpenApi(options =>
|
|
{
|
|
options.AddDocumentTransformer((document, _, _) =>
|
|
{
|
|
document.Info.Title = "FactoryId API";
|
|
document.Info.Description = "Geradores e validadores de identificadores portugueses (NIF, NISS, CC, IBAN, …) para testes.";
|
|
document.Info.Contact = new() { Name = "Marco Santos" };
|
|
return Task.CompletedTask;
|
|
});
|
|
});
|
|
|
|
// API pública, só de leitura e sem credenciais: qualquer origem pode fazer GET.
|
|
builder.Services.AddCors(options =>
|
|
options.AddDefaultPolicy(policy => policy.AllowAnyOrigin().WithMethods("GET").AllowAnyHeader()));
|
|
|
|
var app = builder.Build();
|
|
|
|
app.UseExceptionHandler();
|
|
app.UseStatusCodePages();
|
|
app.UseCors();
|
|
|
|
app.MapOpenApi();
|
|
app.MapScalarApiReference("/docs", options => options.WithTitle("FactoryId API"));
|
|
app.MapGet("/", () => Results.Redirect("/docs")).ExcludeFromDescription();
|
|
app.MapHealthChecks("/health");
|
|
|
|
app.MapGeneratorEndpoints();
|
|
|
|
app.Run();
|
|
|
|
public partial class Program;
|