• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

karanshukla / openresto / 28881805559

07 Jul 2026 04:23PM UTC coverage: 94.253% (+0.07%) from 94.185%
28881805559

Pull #209

github

web-flow
Merge 55996179b into 108a871bd
Pull Request #209: Massive Refactor

4316 of 4939 branches covered (87.39%)

Branch coverage included in aggregate %.

1466 of 1601 new or added lines in 120 files covered. (91.57%)

65 existing lines in 27 files now uncovered.

13954 of 14445 relevant lines covered (96.6%)

83.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.36
/OpenRestoApi/Program.cs
1
using OpenRestoApi.Extensions;
2
using OpenRestoApi.Infrastructure.Exceptions;
3

4
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
30✔
5

6
if (!builder.Environment.IsEnvironment("Testing"))
30!
UNCOV
7
    builder.Configuration.AddJsonFile("appsettings.Local.json", optional: true, reloadOnChange: false);
×
8

9
// Ensure the app listens on the PORT environment variable for Railway, defaulting to 8080
10
builder.WebHost.UseUrls($"http://0.0.0.0:{Environment.GetEnvironmentVariable("PORT") ?? "8080"}");
30!
11

12
builder.WebHost.ConfigureKestrel(options =>
30✔
13
{
30✔
UNCOV
14
    options.AddServerHeader = false;
×
15
});
30✔
16

17
// ProblemDetails backs UseStatusCodePages (bare 404/405 etc.) and [ApiController]
18
// model-state validation. The typed GlobalExceptionHandler runs first for *thrown*
19
// exceptions (AddExceptionHandler registers it ahead of the default ProblemDetails
20
// handler) and owns the {message: "..."} body shape for OpenRestoException types.
21
builder.Services.AddProblemDetails();
30✔
22
builder.Services.AddExceptionHandler<GlobalExceptionHandler>();
30✔
23
builder.Services.AddProjectDependencies();
30✔
24
builder.Services.AddCustomCors(builder.Configuration);
30✔
25
builder.Services.AddCustomRateLimiting(builder.Environment);
30✔
26
builder.Services.AddCustomAuthentication(builder.Configuration);
30✔
27

28
string connectionString = builder.Configuration.GetAppConnectionString(builder.Environment);
30✔
29
builder.Services.AddDatabaseSetup(connectionString, builder.Environment);
30✔
30

31
WebApplication app = builder.Build();
30✔
32

33
// Convert unhandled exceptions and bare status-code responses (404/405/etc.)
34
// into JSON. Must be one of the first middlewares so it can wrap the rest of the
35
// pipeline. Thrown OpenRestoException types are mapped to {message:"..."} by the
36
// registered GlobalExceptionHandler (above); bare status codes fall back to
37
// ProblemDetails via UseStatusCodePages below.
38
app.UseExceptionHandler();
30✔
39
app.UseStatusCodePages();
30✔
40

41
app.UseForwardedHeaders();
30✔
42

43
if (app.Environment.IsDevelopment() || app.Environment.IsEnvironment("Testing"))
30!
44
{
45
    app.MapOpenApi();
30✔
46
}
47

48
app.UseCors("AllowFrontend");
30✔
49

50
app.UseRateLimiter();
30✔
51

52
app.UseAuthentication();
30✔
53
app.UseAuthorization();
30✔
54

55
app.MapControllers();
30✔
56

57
// Anything under /api/* that isn't matched by a controller route returns a
58
// JSON ProblemDetails 404 — never the SPA's HTML index or an empty body.
59
app.MapFallback("/api/{**catchAll}", (HttpContext ctx) =>
30✔
60
    Results.Problem(
38✔
61
        statusCode: StatusCodes.Status404NotFound,
38✔
62
        title: "Not Found",
38✔
63
        detail: $"The requested API endpoint '{ctx.Request.Path}' does not exist."));
38✔
64

65
app.InitializeDatabase(connectionString, builder.Configuration);
30✔
66

67
// Health endpoint: JSON body (consistent with the rest of the API), and opted
68
// out of rate limiting so liveness probes / scanners never get throttled.
69
app.MapGet("/api/health", () => Results.Ok(new { status = "ok" }))
30✔
70
    .DisableRateLimiting();
30✔
71

72
app.Run();
30✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc