Skip to content

Commit

Permalink
feat: Expose reject unauthorized in request helper (#160)
Browse files Browse the repository at this point in the history
Allows to be set service wide or on individual request
fixes #142
  • Loading branch information
jetersen authored and jdalrymple committed Aug 15, 2018
1 parent 77244c6 commit 01a2ce2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/infrastructure/BaseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ class BaseModel {
url = 'https://gitlab.com',
useXMLHttpRequest = false,
version = 'v4',
rejectUnauthorized = true,
} = {}) {
this.url = URLJoin(url, 'api', version);
this.headers = {};
this.requester = useXMLHttpRequest ? XMLHttpRequester : Request;
this.useXMLHttpRequest = useXMLHttpRequest;
this.rejectUnauthorized = rejectUnauthorized;

if (oauthToken) {
this.headers.authorization = `Bearer ${oauthToken}`;
Expand Down
4 changes: 3 additions & 1 deletion src/infrastructure/RequestHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import URLJoin from 'url-join';
import StreamableRequest from 'request';

function defaultRequest(
{ url, useXMLHttpRequest },
{ url, useXMLHttpRequest, rejectUnauthorized },
endpoint,
{
headers,
Expand Down Expand Up @@ -36,6 +36,8 @@ function defaultRequest(

params.resolveWithFullResponse = resolveWithFullResponse;

params.rejectUnauthorized = rejectUnauthorized;

return params;
}

Expand Down

0 comments on commit 01a2ce2

Please sign in to comment.