Skip to content

Commit

Permalink
Refactor formatting and add test endpoints to APIs
Browse files Browse the repository at this point in the history
Improved code readability by adjusting formatting in `Program.cs` files for both Argon.Api and Argon.Entry projects. Added `/test` endpoints to provide basic responses for API and entry path identification. No functional changes were made to existing features.
  • Loading branch information
urumo committed Dec 13, 2024
1 parent 0e79cca commit f5ee05c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
15 changes: 9 additions & 6 deletions src/Argon.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(options => {
builder.WebHost.ConfigureKestrel(options =>
{
options.Limits.KeepAliveTimeout = TimeSpan.FromSeconds(400);
options.AddServerHeader = false;
options.Limits.Http2.MaxStreamsPerConnection = 100;
Expand All @@ -31,18 +32,15 @@
builder.AddRedisClient("cache");
builder.AddNatsStreaming();
builder.Services.AddDbContext<ApplicationDbContext>(x => x
.EnableDetailedErrors()
.EnableSensitiveDataLogging()
.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))
.EnableDetailedErrors().EnableSensitiveDataLogging().UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))
.AddInterceptors(new TimeStampAndSoftDeleteInterceptor()));

builder.Services.AddSingleton<IPasswordHashingService, PasswordHashingService>();
builder.Services.AddHttpContextAccessor();
if (!builder.Environment.IsManaged())
{
builder.AddJwt();
builder.Services.AddControllers()
.AddNewtonsoftJson(x => x.SerializerSettings.Converters.Add(new StringEnumConverter()));
builder.Services.AddControllers().AddNewtonsoftJson(x => x.SerializerSettings.Converters.Add(new StringEnumConverter()));
builder.Services.AddCors(x =>
{
x.AddDefaultPolicy(z =>
Expand All @@ -61,6 +59,7 @@
x.AddService<IEventBus, EventBusService>();
});
}

builder.AddContentDeliveryNetwork();
builder.AddArgonPermissions();
builder.AddSelectiveForwardingUnit();
Expand Down Expand Up @@ -92,4 +91,8 @@
version = $"{GlobalVersion.FullSemVer}.{GlobalVersion.ShortSha}"
});

app.MapGet("/test", () => new
{
path = "api"
});
await app.WarpUp<ApplicationDbContext>().RunAsync();
27 changes: 14 additions & 13 deletions src/Argon.Entry/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
builder.AddContentDeliveryNetwork();
builder.AddServiceDefaults();
builder.AddJwt();
builder.Services.AddControllers()
.AddApplicationPart(typeof(FilesController).Assembly)
builder.Services.AddControllers().AddApplicationPart(typeof(FilesController).Assembly)
.AddNewtonsoftJson(x => x.SerializerSettings.Converters.Add(new StringEnumConverter()));
builder.Services.AddCors(x =>
{
Expand All @@ -37,17 +36,14 @@
});
});
builder.AddSwaggerWithAuthHeader();
builder.Services.AddSerializer(x => x.AddMessagePackSerializer(null, null, MessagePackByteSerializer.Default.Options))
.AddOrleansClient(x =>
{
x.Configure<ClusterOptions>(builder.Configuration.GetSection("Orleans"))
.AddStreaming()
.AddBroadcastChannel(IArgonEvent.Broadcast);
if (builder.Environment.IsProduction())
x.UseKubeGatewayListProvider();
else
x.UseLocalhostClustering();
});
builder.Services.AddSerializer(x => x.AddMessagePackSerializer(null, null, MessagePackByteSerializer.Default.Options)).AddOrleansClient(x =>
{
x.Configure<ClusterOptions>(builder.Configuration.GetSection("Orleans")).AddStreaming().AddBroadcastChannel(IArgonEvent.Broadcast);
if (builder.Environment.IsProduction())
x.UseKubeGatewayListProvider();
else
x.UseLocalhostClustering();
});
builder.AddArgonTransport(x =>
{
x.AddService<IServerInteraction, ServerInteraction>();
Expand All @@ -73,4 +69,9 @@
version = $"{GlobalVersion.FullSemVer}.{GlobalVersion.ShortSha}"
});

app.MapGet("/test", () => new
{
path = "entry"
});

await app.RunAsync();

0 comments on commit f5ee05c

Please sign in to comment.