Files
OptixServe/OptixServe.Api/Endpoints/VersionEndpoint.cs
Huxley Deng 8b18de1735 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.
2025-07-11 14:48:50 +08:00

36 lines
1.0 KiB
C#

using System.Text.Json.Serialization;
using Microsoft.Extensions.Options;
using OptixServe.Infrastructure.Configuration;
using OptixServe.Api.Dtos;
namespace OptixServe.Api.Endpoints;
[JsonSerializable(typeof(string))]
[JsonSerializable(typeof(CommonErrorDto))]
public partial class VersionJsonContext : JsonSerializerContext { }
/// <summary>
/// This is a endpoint ONLY FOR TEST!
/// Should not expect ANY stable behavior on it!
/// </summary>
public static class VersionEndpoint
{
public static void Register(RouteGroupBuilder parentGroup)
{
var group = parentGroup.MapGroup("/version");
group.MapGet("/", () => "v1");
group.MapGet("/test/dbconfig", (IOptions<InfrastructureConfiguration> infrastructureConfig) =>
{
var dbType = infrastructureConfig.Value.Database?.Type;
var dbHost = infrastructureConfig.Value.Database?.Host;
return Results.Ok(new CommonErrorDto
{
Message = $"Set up {dbType} database on {dbHost}"
});
});
}
}