using CMSBLL.Site; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace CMSSL.Endpoints.Site; // Manual/automated verification surface for SiteResolverBLL (Phase 1 — "unit-tested standalone // before anything public-facing depends on it"). The real Phase 2+ render pipeline will call // ISiteResolverBLL directly rather than through HTTP; this endpoint exists purely to prove the // domain -> Site/TenantId resolution works end to end before that pipeline is built on top of it. public class ResolveSiteByDomain : BaseEndpoint { private readonly ISiteResolverBLL _resolver; public ResolveSiteByDomain(ISiteResolverBLL resolver) => _resolver = resolver; public override void Configure() { Get("/Site/ResolveSiteByDomain"); AllowAnonymous(); } public record Parameters([property: QueryParam] string DomainName, [property: FromHeader] string Login); protected override async Task> ExecuteAsync(Parameters req, LoginDTO login, CancellationToken ct) { try { var result = await _resolver.ResolveByDomainAsync(req.DomainName, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }