Skip to content

Commit

Permalink
fixup! Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Mar 19, 2020
1 parent 0006084 commit 61aa8ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-che/workspace-client",
"version": "0.0.1",
"name": "@ivinokur/workspace-client",
"version": "0.0.9",
"description": "",
"main": "dist/server.js",
"browser": "dist/client.js",
Expand Down
13 changes: 7 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface IRestAPIConfig {
headers?: any;
// path to self signed certificate
ssCrtPath?: string;
loggingEnabled?: boolean;
}

export default class WorkspaceClient {
Expand All @@ -47,7 +48,7 @@ export default class WorkspaceClient {

private static createAxiosInstance(config: IRestAPIConfig): AxiosInstance {
if (!this.isItNode()) {
this.addLogInterceptorsIfEnabled(axios);
this.addLogInterceptorsIfEnabled(axios, config);
return axios;
}

Expand Down Expand Up @@ -79,7 +80,7 @@ export default class WorkspaceClient {
axiosRequestConfig.httpAgent = proxyIsHttps ? httpsOverHttpsAgent : httpOverHttpsAgent;
}
const axiosInstance = axios.create(axiosRequestConfig);
this.addLogInterceptorsIfEnabled(axiosInstance);
this.addLogInterceptorsIfEnabled(axiosInstance, config);
return axiosInstance;
}
}
Expand All @@ -89,19 +90,19 @@ export default class WorkspaceClient {
ca: certificateAuthority
})
});
this.addLogInterceptorsIfEnabled(axiosInstance);
this.addLogInterceptorsIfEnabled(axiosInstance, config);
return axiosInstance;
}
this.addLogInterceptorsIfEnabled(axios);
this.addLogInterceptorsIfEnabled(axios,config);
return axios;
}

private static isItNode() {
return (typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined');
}

private static addLogInterceptorsIfEnabled(axiosInstance: AxiosInstance) {
if (!process.env.HTTP_REQUEST_LOG) {
private static addLogInterceptorsIfEnabled(axiosInstance: AxiosInstance, config: IRestAPIConfig) {
if (!config.loggingEnabled) {
return;
}
axiosInstance.interceptors.request.use(request => {
Expand Down

0 comments on commit 61aa8ca

Please sign in to comment.