From 03a8154b1c91fc4d61443f8dfcb59af1b3e4235f Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 30 Jan 2026 09:43:26 +0100 Subject: [PATCH] Add ConfigController to expose annotation config via API Introduced a secured ConfigController with a GET endpoint at /api/Config/Annotations to provide annotation configuration data to clients. Utilizes dependency injection for configuration and includes necessary using directives. --- .../Controllers/ConfigController.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 EnvelopeGenerator.GeneratorAPI/Controllers/ConfigController.cs diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/ConfigController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/ConfigController.cs new file mode 100644 index 00000000..2bc35c64 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Controllers/ConfigController.cs @@ -0,0 +1,29 @@ +using EnvelopeGenerator.GeneratorAPI.Models.Annotation; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; + +namespace EnvelopeGenerator.GeneratorAPI.Controllers; + +/// +/// Exposes configuration data required by the client applications. +/// +/// +/// Initializes a new instance of . +/// +[Route("api/[controller]")] +[ApiController] +[Authorize] +public class ConfigController(IOptionsMonitor annotationParamsOptions) : ControllerBase +{ + private readonly AnnotationParams _annotationParams = annotationParamsOptions.CurrentValue; + + /// + /// Returns annotation configuration that was previously rendered by MVC. + /// + [HttpGet("Annotations")] + public IActionResult GetAnnotationParams() + { + return Ok(_annotationParams.AnnotationJSObject); + } +}