1.0.2 • Published 4 months ago

@aster-js/http v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
4 months ago

@aster-js/http

Main concept

This library introduce an HttpClient that works using an execution pipeline through chain of IRequestHandler.

It also use a core concept of @aster-js/async: AbortToken. They are used through the pipeline allowing to cancel any pipeline that still run.

// You can provide your own root RequestHandler, very use full for Unit Testing
const httpClient = new HttpClient()
    // Sync or async configuration
    .configure(async options => {
        options.headers = {
            "Content-Type": await AuthorizationManager.getToken()
        };
    })
    // Multiple RequestHandler implementation:
    // timeout, caching, dynamic configuration or custom implementations
    .pipe(TimeoutRequestHandler, 30 * 1000);



httpClient.get("/data", HttpBody.json())

Resiliency

@aster-js/resilient provide a ResilientRequestHandler that provide advance way to handle retrys.