Web

The Devprime platform offers an adapter for API exposure and web exposure implementation through the ASP.NET/Razor/Minimal API, with integration to security, performance, and intelligent processing mechanisms using Devprime Pipeline.

The Devprime platform architecture adopts an approach that isolates the responsibilities of each technological layer and business rules. This simplifies the maintenance and evolution of services. For each API, requests are directed to App Service, which in turn routes business processing to the domain (Core/Domain). This structure helps maintain a clear separation of concerns and facilitates the development and maintenance of complex systems.

Exposure of APi’s using Minimal API in the Web Adapter

In the example presented below, we have the exposure of APIs with the routes implemented in the Adapter Web. The business flow is delivered to the application service, following the fundamental principles of the architecture, which prioritize maintainability, reuse, and testability. This means that the structure of the code is designed in a way that makes it easy to maintain in the long term, allowing the efficient use of components in different parts of the system and the performance of tests effectively.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace DevPrime.Web;
public class Order : Routes
{
    public override void Endpoints(WebApplication app)
    {
        //Automatically returns 404 when no result  
        app.MapGet("/v1/order", async (HttpContext http, 
        IOrderService Service, int? limit, int? offset, 
        string ordering, string ascdesc, string filter)
        => await Dp(http).Pipeline(() => Service.GetAll
        (new Application.Services.Order.Model.Order(limit, 
        offset, ordering, ascdesc, filter)), 404));
        
        //Automatically returns 404 when no result 
        app.MapGet("/v1/order/{id}", async (HttpContext http,
        IOrderService Service, Guid id) => await 
        Dp(http).Pipeline(() => Service.Get(
        new Application.Services.Order.Model.Order(id)), 404));
        
        app.MapPost("/v1/order", async (HttpContext http,
        IOrderService Service,DevPrime.Web.Models.Order.Order
        command) => await Dp(http).Pipeline(()
         => Service.Add(command.ToApplication())));

        app.MapPut("/v1/order", async (HttpContext http,
        IOrderService Service,
        Application.Services.Order.Model.Order command) => 
        await Dp(http).Pipeline(() => Service.Update(command)));
        
        app.MapDelete("/v1/order/{id}", async (HttpContext http,
        IOrderService Service, Guid id) => await 
        Dp(http).Pipeline(() => Service.Delete(
        new Application.Services.Order.Model.Order(id))));
    }
}

APIs automatically exposed by Swagger"
Devprime Web Adapter


Last modified August 20, 2024 (2f9802da)