Skip to content

Commit 6e2af92

Browse files
committed
chore: Migrate configuration files from JSON to HOCON format
- Add the dependency for the HOCON configuration provider package - Update Program.cs to load .conf files instead of .json files - Remove the original JSON configuration files - Add the corresponding HOCON configuration files
1 parent a88cf31 commit 6e2af92

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

src/Limekuma.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,23 @@
2727
<PrivateAssets>all</PrivateAssets>
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2929
</PackageReference>
30+
<PackageReference Include="Hocon" Version="2.0.4" />
31+
<PackageReference Include="Hocon.Extensions.Configuration" Version="2.0.4" />
32+
<PackageReference Include="Microsoft.NETCore.Platforms" Version="7.0.4" />
33+
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
3034
<PackageReference Include="SixLabors.Fonts" Version="2.1.3" />
3135
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
3236
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
3337
<PackageReference Include="Grpc.AspNetCore" Version="2.76.0" />
3438
</ItemGroup>
3539

40+
<ItemGroup>
41+
<None Update="appsettings.conf">
42+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
43+
</None>
44+
<None Update="appsettings.Development.conf">
45+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
46+
</None>
47+
</ItemGroup>
48+
3649
</Project>

src/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
using Hocon.Extensions.Configuration;
12
using Limekuma.Services;
23

34
WebApplicationBuilder builder = WebApplication.CreateSlimBuilder(args);
45

6+
builder.Configuration.AddHoconFile("appsettings.conf", true, true)
7+
.AddHoconFile($"appsettings.{builder.Environment.EnvironmentName}.conf", true, true);
58
builder.Services.AddGrpc(options => options.EnableDetailedErrors = true);
69

710
await using WebApplication app = builder.Build();

src/appsettings.Development.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Logging {
2+
LogLevel {
3+
Default = "Information"
4+
"Microsoft.AspNetCore" = "Warning"
5+
}
6+
}

src/appsettings.Development.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/appsettings.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Logging {
2+
LogLevel {
3+
Default = "Information"
4+
"Microsoft.AspNetCore" = "Warning"
5+
}
6+
}
7+
AllowedHosts = "*"
8+
Kestrel {
9+
EndpointDefaults {
10+
Protocols = "Http2"
11+
}
12+
}

src/appsettings.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)