using System.Text.Json; namespace VPNAuth.Server; public class ConfigUser { public string? Username { get; set; } public List? Ips { get; set; } } public class ConfigApp { public string? ClientId { get; set; } public string? RedirectUri { get; set; } public string? Secret { get; set; } } public class Config { public List? Users { get; set; } public List? Apps { get; set; } public ConfigApp? FindApp(string clientId) => Apps?.Find(app => app.ClientId == clientId); private static string _filePath = "./config.json"; public static void CreateIfNotExists() { if (File.Exists(_filePath)) return; File.Create(_filePath); File.WriteAllText(_filePath, JsonSerializer.Serialize(new Config { Users = [] })); } public static Config Read() => JsonSerializer.Deserialize(File.ReadAllText(_filePath))!; }