Refactor workflows and improve API responses
- Added `BackToPerMethodId` constant and updated validation rules in `CloseWorkflowCommandValidator`. - Refactored `GetWorkflowsQueryHandler` for simpler `hasListingData` logic. - Replaced strongly-typed properties with `JsonElement` in `ContractsSourceBlock` and `FerdinandSourceBlock`. - Updated `WorkflowListingReadModel` to use smaller data types for efficiency. - Refactored `WorkflowRepository` to use JSON-based data retrieval and parsing. - Introduced `MetaOnlyResponse` and `WorkflowsResponse` for consistent API responses. - Updated `DocumentsController` and `WorkflowsController` to use new response types. - Added `ApiKeyAuthMiddleware` for API key validation and integrated it into the middleware pipeline. - Refactored `ExceptionHandlingMiddleware` to use `MetaOnlyResponse` for error handling. - Performed general cleanup and modernization for improved readability and maintainability.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using DigitalData.TaskFlow.Application.Features.Documents.Queries.GetDocument;
|
||||
using DigitalData.TaskFlow.API.Contracts.Common;
|
||||
using DigitalData.TaskFlow.Domain.Common;
|
||||
using DigitalData.TaskFlow.Domain.Documents;
|
||||
using MediatR;
|
||||
@@ -21,9 +22,11 @@ public sealed class DocumentsController(ISender sender) : ControllerBase
|
||||
/// <returns>Binary stream when available.</returns>
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ApiEnvelope<object>), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(ApiEnvelope<object>), StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(typeof(ApiEnvelope<object>), StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await sender.Send(new GetDocumentQuery(id), cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user