/https-keepalive-proxy-tunnel

A library to keep-alive and write requests directly onto a Net/TLS socket for HTTP and HTTPS requests.

Primary LanguageTypeScriptMIT LicenseMIT

https-keepalive-proxy-tunnel

A library to keep-alive and write requests directly onto a Net/TLS socket for HTTP and HTTPS requests.

NPM Package Build Status Coverage Status TypeCov Codechecks

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 6.0 or higher is required.

Installation is done using the npm install command:

# NPM Users
$ npm install --save @robinlemon/https-keepalive-proxy-tunnel

# Yarn Users
$ yarn add @robinlemon/https-keepalive-proxy-tunnel

Usage

Quickstart

import { Agent } from '@robinlemon/https-keepalive-proxy-tunnel';

/**
 * Simple
 */
const { Body, Response, StatusCode } = await Agent.Request('https://www.google.com/', 'http://username?:password?@domain-or-ip:port?/');

/**
 * Custom Types
 */
interface IApiResponse {
    response: {
        id: number;
        name: string;
    }[];
}
const { Body, Response, StatusCode } = await Agent.Request<IApiResponse>(
    'https://www.google.com/some/random/api/path/post',
    'http://username?:password?@domain-or-ip:port?/',
    {
        Method: 'POST',
        Headers: {
            'X-CSRF-TOKEN': 'MySecurityToken',
        },
    },
);

See __tests__ for more examples.

Tests

To run the test suite, first install the dependencies, then run npm test:

# NPM Users
$ npm install
$ npm test

# Yarn Users
$ yarn
$ yarn test

License

MIT