6.0.0 • Published 6 years ago
crest-client-core v6.0.0
Crest Client Core
The core api for the crest-client starter project. Look here if you are thinking of building your own crest-client-mechanism package! Otherwise come over to crest-client
Crest Mechanisms
Crest Client, aims to be non-opinionated about libraries. Crest introduces 3 interfaces for handling the request lifecycle: 1. CacheMechanism 2. LogMechanism 3. HttpMechanism
/**
* CacheMechanism - a basic key value store for caching result sets.
*/
export interface CacheMechanism {
set(key: string, data: any): Promise<void>;
get(key: string): Promise<any>;
clear(key: string): Promise<void>;
}
/**
* LogMechanism - provides a means to log events of the request lifecycle.
* Provides 'Performance' class for key performance metrics.
*/
export interface LogMechanism {
before(host: Host, request: Request): any;
after(host: Host, request: Request, performance: Performance): any;
}
/**
* HttpMechanism - responsible for sending the http request.
* Should embed the authToken in the HTTP Authorization Header.
* Upon success, should call the success function. Otherwise should call the error function with the specified error.
*/
export interface HttpMechanism {
send(host: Host, request: Request, authToken: string, success: (output: any) => void, error: (error: CrestError) => void): any;
}