< Summary

Information
Class: Program
Assembly: Despesas.Backend
File(s): /src/Despesas.Backend/Program.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 70
Coverable lines: 70
Total lines: 105
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 16
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
<Main>$(...)0%272160%

File(s)

/src/Despesas.Backend/Program.cs

#LineLine coverage
 1using CrossCutting.CommonDependenceInject;
 2using Despesas.Application.CommonDependenceInject;
 3using Despesas.Backend.CommonDependenceInject;
 4using Despesas.Infrastructure.CommonDependenceInject;
 5using Microsoft.EntityFrameworkCore;
 6using Repository;
 7using Repository.CommonDependenceInject;
 8using Despesas.GlobalException.CommonDependenceInject;
 9
 010var builder = WebApplication.CreateBuilder(args);
 11
 12// Add Cors Configurations
 013builder.Services.AddCors(options =>
 014{
 015    options.AddDefaultPolicy(policy =>
 016    {
 017        policy.WithOrigins(
 018            "https://alexfariakof.com",
 019            "https://alexfariakof.com:42535",
 020            "https://localhost",
 021            "https://localhost:42535",
 022            "https://localhost:4200",
 023            "https://127.0.0.1",
 024            "https://127.0.0.1:4200",
 025            "https://127.0.0.1:42535",
 026            "https://accounts.google.com")
 027        .AllowAnyMethod()
 028        .AllowAnyHeader()
 029        .AllowCredentials();
 030    });
 031});
 32
 033builder.Services.AddRouting(options => options.LowercaseUrls = true);
 034builder.Services.AddControllers();
 035builder.Services.AddSwaggerApiVersioning();
 36
 37
 038if (builder.Environment.IsStaging() || builder.Environment.IsDevelopment())
 039{
 040    builder.Services.AddDbContext<RegisterContext>(options => options
 041    .UseLazyLoadingProxies()
 042    .UseMySQL(builder.Configuration.GetConnectionString("Dev.SqlConnectionString") ??
 043        throw new NullReferenceException("SqlConnectionString not defined.")));
 044}
 45else
 046{
 047    builder.Services.AddDbContext<RegisterContext>(options => options
 048    .UseMySQL(builder.Configuration.GetConnectionString("SqlConnectionString") ??
 049        throw new NullReferenceException("SqlConnectionString not defined.")));
 050}
 51
 52//Add SigningConfigurations
 053builder.AddSigningConfigurations();
 54
 55// Add AuthConfigurations
 056builder.AddAuthenticationConfigurations();
 57
 58// Add Cryptography Configurations
 059builder.Services.AddServicesCryptography(builder.Configuration);
 60
 61// Add CommonDependencesInject
 062builder.Services.AddAutoMapper();
 063builder.Services.AddAmazonS3BucketConfigurations(builder.Configuration);
 064builder.Services.AddRepositories();
 065builder.Services.AddServices();
 066builder.Services.AddCrossCuttingConfiguration();
 67
 068if (builder.Environment.IsStaging())
 069{
 070    builder.WebHost.UseUrls("https://0.0.0.0:42535", "http://0.0.0.0:42536");
 071}
 72
 73// remove todos os providers (Console, Debug, EventLog etc.) Mata Kubernetes
 074if (builder.Environment.IsProduction() || builder.Environment.IsStaging())
 075    builder.Logging.ClearProviders();
 76
 077var app = builder.Build();
 78
 79//Configure Global Execeptions
 080app.UseGlobalExceptionHandler();
 81
 82// Configure the HTTP request pipeline
 083app.UseHsts();
 84
 085app.UseHttpsRedirection();
 086app.AddSupporteCulturesPtBr();
 087app.UseCors();
 088app.AddSwaggerUIApiVersioning();
 089app.UseDefaultFiles();
 090app.UseStaticFiles();
 091app.UseRouting();
 092app.UseCertificateForwarding();
 093app.UseAuthentication();
 094app.UseAuthorization();
 95
 096app.MapControllers();
 097app.MapFallbackToFile("index.html");
 98
 099if (app.Environment.IsStaging())
 0100{
 0101    app.Urls.Add("https://0.0.0.0:42535");
 0102    app.Urls.Add("http://0.0.0.0:42536");
 0103}
 104
 0105app.Run();

Methods/Properties

<Main>$(System.String[])