@stackfactor/client-api 1.0.60 → 1.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import axios from "axios";
2
+ import { RESPONSE_TYPE } from "./constants.js";
2
3
  import https from "https";
3
4
  import utils from "./utils.js";
4
5
 
@@ -15,7 +16,7 @@ const client = axios.create({
15
16
  * Returns the error as a string
16
17
  * @param {Object} error
17
18
  */
18
- export const errorToString = (error) => {
19
+ const errorToString = (error) => {
19
20
  if (error != null) {
20
21
  if (error?.response?.data) {
21
22
  let asString = "";
@@ -44,10 +45,10 @@ export const errorToString = (error) => {
44
45
  * @param {Object} error
45
46
  * @returns {Number} The error code
46
47
  */
47
- export const getErrorType = (error) => {
48
+ const getErrorType = (error) => {
48
49
  if (error?.response?.status) {
49
50
  return error.response.status;
50
- } else return responseType.SERVICE_UNAVAILABLE;
51
+ } else return RESPONSE_TYPE.SERVICE_UNAVAILABLE;
51
52
  };
52
53
 
53
54
  /**
@@ -55,7 +56,7 @@ export const getErrorType = (error) => {
55
56
  * @param {Object} error
56
57
  * @returns Object
57
58
  */
58
- export const getErrorInformation = (error) => {
59
+ const getErrorInformation = (error) => {
59
60
  return {
60
61
  status: getErrorType(error),
61
62
  message: errorToString(error),
@@ -67,8 +68,8 @@ export const getErrorInformation = (error) => {
67
68
  * @param {Boolean} returnAllExceptions - If set true all exceptions will be passed
68
69
  * @param {Object} error - The error returned by the server
69
70
  */
70
- export const shouldReturnError = (returnAllExceptions, error) => {
71
- if (getErrorType(error) === responseType.UNAUTHORIZED) {
71
+ const shouldReturnError = (returnAllExceptions, error) => {
72
+ if (getErrorType(error) === RESPONSE_TYPE.UNAUTHORIZED) {
72
73
  return returnAllExceptions;
73
74
  } else {
74
75
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackfactor/client-api",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "description": "Node.js library for the StackFactor API",
5
5
  "main": "index.js",
6
6
  "exports": {