Skip to content

Commit

Permalink
refactor: use consts for name of feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ktos committed Jun 14, 2024
1 parent c19a1a1 commit 704ddbe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Server/Modules/Items/Services/ItemGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Fracture.Server.Modules.AI.Services;
using Fracture.Server.Modules.Items.Models;
using Fracture.Server.Modules.Shared;
using Fracture.Server.Modules.Shared.Configuration;
using Microsoft.FeatureManagement;
using System.Text.Json;

Expand Down Expand Up @@ -103,7 +104,7 @@ public async Task<Item> Generate()

await _prefixes.AddPrefixes(item);

if (await _featureManager.IsEnabledAsync("UseAI"))
if (await _featureManager.IsEnabledAsync(FeatureFlags.USE_AI))
{
item.History = await GenerateDescription(item);
}
Expand Down
8 changes: 8 additions & 0 deletions Server/Modules/Shared/Configuration/FeatureFlags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Fracture.Server.Modules.Shared.Configuration
{
public static class FeatureFlags
{
public const string CONFIG_SECTION = "FeatureFlags";
public const string USE_AI = "UseAI";
}
}
4 changes: 3 additions & 1 deletion Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
builder.Services.AddScoped<IUsersRepository, UsersRepository>();
builder.Services.AddScoped<IItemsRepository, ItemsRepository>();

builder.Services.AddFeatureManagement(builder.Configuration.GetSection("FeatureFlags"));
builder.Services.AddFeatureManagement(
builder.Configuration.GetSection(FeatureFlags.CONFIG_SECTION)
);

builder.Services
.AddRazorComponents()
Expand Down

0 comments on commit 704ddbe

Please sign in to comment.