using Expose.MyIT.Shared.Models.Stateless.Methods; using Microsoft.AspNetCore.Mvc; using System.Text.Json; namespace Expose.MyIT.Server.Controllers; [ApiController] public class AppSettingsController : ControllerBase, IAppSettingsController { private readonly Models.AppSettings _AppSettings; public AppSettingsController(Models.AppSettings appSettings) => _AppSettings = appSettings; [Route("api/[controller]")] [HttpGet] public string[] GetAppSettings() { List results = new(); string json = JsonSerializer.Serialize(_AppSettings); JsonElement jsonElement = JsonSerializer.Deserialize(json); JsonProperty[] jsonProperties = jsonElement.EnumerateObject().ToArray(); foreach (JsonProperty jsonProperty in jsonProperties) results.Add(jsonProperty.Value.ToString()); if (!_AppSettings.IsDevelopment) throw new Exception("Shouldn't expose!"); return results.ToArray(); } }