This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -361,3 +361,6 @@ MigrationBackup/
|
|||||||
|
|
||||||
# Fody - auto-generated XML schema
|
# 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);
|
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");
|
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;
|
SetupSettings setup;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!File.Exists(setupFilePath))
|
|
||||||
throw new Exception("setup.json saknas.");
|
|
||||||
|
|
||||||
using var jsonStream = File.OpenRead(setupFilePath);
|
using var jsonStream = File.OpenRead(setupFilePath);
|
||||||
setup = JsonSerializer.Deserialize<SetupSettings>(jsonStream)!;
|
setup = JsonSerializer.Deserialize<SetupSettings>(jsonStream)!;
|
||||||
|
|
||||||
@@ -51,6 +63,7 @@ catch (Exception ex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add services to the container
|
// Add services to the container
|
||||||
builder.Services.AddControllersWithViews()
|
builder.Services.AddControllersWithViews()
|
||||||
.AddJsonOptions(opts =>
|
.AddJsonOptions(opts =>
|
||||||
|
|||||||
Reference in New Issue
Block a user