Split the backend into API host, Domain, Application and Infrastructure projects. Add Swagger/OpenAPI per API version, Asp.Versioning (query/header), ProblemDetails with a global exception handler and SurrealQL migrations applied at startup (namespace/database ensured). Infrastructure owns the SurrealDB client, settings and DI.
22 lines
706 B
C#
22 lines
706 B
C#
namespace TarninaHub.Infrastructure.Settings;
|
|
|
|
public static class SurrealDbEndpoint
|
|
{
|
|
/// <summary>
|
|
/// Builds the SurrealDB endpoint. Remote mode uses the configured URL;
|
|
/// embedded mode uses the RocksDB provider persisted to the data directory
|
|
/// (forward slashes, so the same endpoint works on Windows and Linux).
|
|
/// </summary>
|
|
public static string Build(SurrealDbSettings settings)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(settings.RemoteUrl))
|
|
{
|
|
return settings.RemoteUrl;
|
|
}
|
|
|
|
var dataDirectory = Path.Combine(AppContext.BaseDirectory, settings.DataDirectory);
|
|
|
|
return $"rocksdb://{dataDirectory.Replace('\\', '/')}";
|
|
}
|
|
}
|