@burstjs/http
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "@burstjs/http", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Send commands to BURST over HTTP", | ||
@@ -17,3 +17,4 @@ "contributors": [ | ||
"license": "GPL-3.0", | ||
"main": "./src/index.ts", | ||
"main": "./out/src/index.js", | ||
"typings": "./out/src/index.d.ts", | ||
"private": false, | ||
@@ -38,2 +39,3 @@ "jest": { | ||
"test": "jest", | ||
"tsc": "tsc", | ||
"doc": "./node_modules/.bin/esdoc" | ||
@@ -49,3 +51,3 @@ }, | ||
}, | ||
"gitHead": "e7655283fbe300b4e353c5e15c097d240254c975", | ||
"gitHead": "9e038b8737cd2359d8888dca4bcd98c456b3e3f7", | ||
"publishConfig": { | ||
@@ -52,0 +54,0 @@ "access": "public" |
import axios from 'axios'; | ||
import HttpResponse from './httpResponse'; | ||
import HttpError from './httpError'; | ||
/** | ||
* An generic HTTP client | ||
* A generic HTTP client | ||
*/ | ||
@@ -22,9 +23,9 @@ class Http { | ||
static _getErrorResponse(error: any): HttpResponse { | ||
static mountError(url: string, error: any): HttpError { | ||
if (error.response) { | ||
return new HttpResponse(error.response.status, error.response.statusText, error.response.data); | ||
return new HttpError(url, error.response.status, error.response.statusText, error.response.data); | ||
} else if (error.request) { | ||
return new HttpResponse(0, error.request, 'Request failed'); | ||
return new HttpError(url, 0, 'Request failed', error.request); | ||
} | ||
return new HttpResponse(-1, '', 'Axios Configuration error'); | ||
return new HttpError(url, -1, 'Http Configuration error', null); | ||
} | ||
@@ -42,3 +43,3 @@ | ||
} catch (error) { | ||
return Http._getErrorResponse(error); | ||
throw Http.mountError(url, error); | ||
} | ||
@@ -58,3 +59,3 @@ } | ||
} catch (error) { | ||
return Http._getErrorResponse(error); | ||
throw Http.mountError(url, error); | ||
} | ||
@@ -74,3 +75,3 @@ } | ||
} catch (error) { | ||
return Http._getErrorResponse(error); | ||
throw Http.mountError(url, error); | ||
} | ||
@@ -89,3 +90,3 @@ } | ||
} catch (error) { | ||
return Http._getErrorResponse(error); | ||
throw Http.mountError(url, error); | ||
} | ||
@@ -92,0 +93,0 @@ } |
@@ -1,4 +0,5 @@ | ||
/* | ||
* Copyright 2018 PoC-Consortium | ||
*/ | ||
/** | ||
* Original work Copyright (c) 2018 PoC-Consortium | ||
* Modified work Copyright (c) 2019 Burst Apps Team | ||
*/ | ||
@@ -9,21 +10,7 @@ /* | ||
* Thrown on HTTP errors | ||
* | ||
*/ | ||
export default class HttpError { | ||
public status: number; | ||
public error: string; | ||
public exception: string; | ||
public message: string; | ||
public path: string; | ||
public timestamp: Date; | ||
public errorCode: number; | ||
constructor (data: any = {}) { | ||
this.status = data.status || 0; | ||
this.error = data.error || ''; | ||
this.exception = data.exception || ''; | ||
this.message = data.message || ''; | ||
this.path = data.path || ''; | ||
this.timestamp = data.timestamp || Date.now(); | ||
this.errorCode = data.errorCode || 0; | ||
} | ||
public timestamp: number = Date.now(); | ||
constructor(public requestUrl: string, public status: number, public message: string, public data: any) {} | ||
} |
class HttpResponse { | ||
constructor(public status: number, public response: any, public error?: string) {} | ||
hasError() { return !!this.error; } | ||
constructor(public status: number, public response: any) {} | ||
} | ||
export default HttpResponse; |
/** @module http */ | ||
import Github from './github'; | ||
import Http from './http'; | ||
import HttpResponse from './httpResponse'; | ||
import HttpError from './httpError'; | ||
import HttpMock from './httpMock'; | ||
export { | ||
Github, | ||
Http, | ||
HttpResponse, | ||
HttpMock, | ||
HttpError | ||
}; | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": [ | ||
"es2015" | ||
], | ||
"noImplicitThis": true, | ||
"strict": true, | ||
"outDir": "out", | ||
"declaration": true, | ||
"declarationDir": "typings", | ||
"sourceMap": true, | ||
"outDir": "./out", | ||
"types": [ | ||
@@ -17,10 +9,10 @@ "axios", | ||
], | ||
"typeRoots": [ | ||
"node_modules/@types" | ||
] | ||
}, | ||
"typeRoots": [ | ||
"typings", | ||
"node_modules/@types" | ||
], | ||
"include": [ | ||
"src", | ||
"__tests__" | ||
"./src" | ||
] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21976
24
468
1