0.2.14 • Published 4 years ago
https-adapter v0.2.14
https-adapter
A module for making configured HTTPS requests
Usage
Install it by:
npm install --save https-adapter
yarn add https-adapter
Create all needed configuration for your HTTPS request and then invoke makeRequest():
let httpsConfig: IHttpsConfiguration = {
baseUrl: 'hostname.com',
pathname: '/',
headers: {
"Content-Type": "application/json"
},
method: GET
};
// Output logs to console.log();
let response: IHttpResponse = await makeRequest(httpsConfig, true);
Types definitions
declare namespace httpsRepository
{
interface IHttpsConfiguration
{
baseUrl: string;
pathname: string;
method: string;
headers: OutgoingHttpHeaders;
queryString?: string;
payload?: any;
};
interface IHttpResponse
{
statusCode: number;
body: string;
headers?: IncomingHttpHeaders;
};
interface IAws4Configs
{
service: string;
region: string;
secret: any;
key: any;
};
// Regular Requests
function makeRequest(httpsConfig: IHttpsConfiguration, showLogs?: boolean): Promise<IHttpResponse>;
// AWS4 Signed Requests
function makeAws4SignedRequest(aws4Config: IAws4Configs, httpsConfig: IHttpsConfiguration, showLogs?: boolean): Promise<IHttpResponse>;
}