BRAKING refactor project structure.
Refactor: the project is now divided into a more clear structure, with **Infrastructure** and **Application** layers added. Refactor: configurations are split into sections for different layers. Fix: now EF Core related operations, such as migration, should be invoked in `OptixServe.Infrastructure`, with config file and data dir passed into `dotnet ef` command. See `OptixServe.Infrastructure/Utilites/DesignTimeDbContextFactory.cs` for details. Fix: EF migrations are ignored in gitignore on purpose in early development.
This commit is contained in:
@ -1,16 +1,15 @@
|
||||
namespace OptixServe.Api.Configuration;
|
||||
|
||||
public record OptixServeSettings
|
||||
public record ApiConfiguration
|
||||
{
|
||||
public ApiSettings? Api { get; set; } = new();
|
||||
public DatabaseSettings? Database { get; set; } = new();
|
||||
public JwtSettings? Jwt { get; set; } = new();
|
||||
}
|
||||
|
||||
public record ApiSettings
|
||||
{
|
||||
public string? Listen { get; set; } = "127.0.0.1";
|
||||
public int? Port { get; set; } = 10086;
|
||||
public string? Listen { get; set; }
|
||||
public int? Port { get; set; }
|
||||
}
|
||||
|
||||
public record JwtSettings
|
||||
@ -20,15 +19,3 @@ public record JwtSettings
|
||||
public string Audience { get; set; } = "OptixServeUsers";
|
||||
public int TokenExpirationMinutes { get; set; } = 60;
|
||||
}
|
||||
|
||||
public enum DatabaseType
|
||||
{
|
||||
Sqlite,
|
||||
MySQL
|
||||
}
|
||||
|
||||
public record DatabaseSettings
|
||||
{
|
||||
public DatabaseType Type { get; set; } = DatabaseType.Sqlite;
|
||||
public string? Host { get; set; }
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace OptixServe.Api.Configuration;
|
||||
|
||||
public static class ConfigurationHelper
|
||||
{
|
||||
public static IConfigurationBuilder CreateDefaultBuilder()
|
||||
{
|
||||
var aspEnv = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
var netEnv = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
|
||||
// Console.WriteLine($"ASPNETCORE_ENVIRONMENT: {aspEnv}, DOTNET_ENVIRONMENT: {netEnv}");
|
||||
var env = aspEnv ?? netEnv ?? null;
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", optional: true)
|
||||
.AddJsonFile("config.json", optional: true);
|
||||
|
||||
if (env != null)
|
||||
{
|
||||
builder.AddJsonFile($"appsettings.{env}.json", optional: true)
|
||||
.AddJsonFile($"config.{env}.json", optional: true);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user