This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -360,4 +360,7 @@ MigrationBackup/
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
FodyWeavers.xsd
|
||||
|
||||
# Setupfil för Aberwyn
|
||||
infrastructure/setup.json
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"AdminUsername": "tai",
|
||||
"AdminEmail": "tai@zcz.se",
|
||||
"AdminPassword": "Admin123!",
|
||||
"IsConfigured": true,
|
||||
"DbHost": "localhost",
|
||||
"DbPort": 3306,
|
||||
"DbName": "aberwyn_test",
|
||||
"DbUser": "root",
|
||||
"DbPassword": "rootpass"
|
||||
}
|
||||
@@ -22,14 +22,26 @@ var builder = WebApplication.CreateBuilder(new WebApplicationOptions
|
||||
});
|
||||
builder.Configuration.AddConfiguration(config);
|
||||
|
||||
// Läser setup.json
|
||||
|
||||
// Läser setup.json eller skapar en ny tom om den inte finns
|
||||
var setupFilePath = Path.Combine("infrastructure", "setup.json");
|
||||
|
||||
if (!File.Exists(setupFilePath))
|
||||
{
|
||||
var initialSettings = new SetupSettings
|
||||
{
|
||||
IsConfigured = false,
|
||||
DbPort = 3306
|
||||
};
|
||||
|
||||
var initialJson = JsonSerializer.Serialize(initialSettings, new JsonSerializerOptions { WriteIndented = true });
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(setupFilePath)!); // säkerställ att mappen finns
|
||||
File.WriteAllText(setupFilePath, initialJson);
|
||||
}
|
||||
|
||||
SetupSettings setup;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(setupFilePath))
|
||||
throw new Exception("setup.json saknas.");
|
||||
|
||||
using var jsonStream = File.OpenRead(setupFilePath);
|
||||
setup = JsonSerializer.Deserialize<SetupSettings>(jsonStream)!;
|
||||
|
||||
@@ -51,6 +63,7 @@ catch (Exception ex)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add services to the container
|
||||
builder.Services.AddControllersWithViews()
|
||||
.AddJsonOptions(opts =>
|
||||
|
||||
Reference in New Issue
Block a user