Web

The Devprime platform provides 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 architecture of the Devprime platform takes an approach that isolates the responsibilities of each technology layer and business rules. This simplifies the maintenance and evolution of services. In the case of each API, requests are directed to the Application Service, which, in turn, forwards business processing to the domain (Core/Domain). This framework helps maintain a clear separation of concerns and makes it easier to develop and maintain 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 Web Adapter. 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 run, allowing for 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 January 10, 2024 (967dcac3)