@verdocs/js-sdk 2.0.6 → 2.0.7
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.
- package/VerdocsEndpoint.js +10 -7
- package/package.json +1 -1
package/VerdocsEndpoint.js
CHANGED
|
@@ -2,6 +2,9 @@ import axios from 'axios';
|
|
|
2
2
|
import { decodeAccessTokenBody } from './Utils/Token';
|
|
3
3
|
import globalThis from './Utils/globalThis';
|
|
4
4
|
import * as Documents from './Documents';
|
|
5
|
+
// @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
|
|
6
|
+
// Also see globalThis for comments about why we're doing this in the first place.
|
|
7
|
+
var ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
|
|
5
8
|
var requestLogger = function (r) {
|
|
6
9
|
// tslint:disable-next-line
|
|
7
10
|
console.debug("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
|
|
@@ -65,6 +68,13 @@ var VerdocsEndpoint = /** @class */ (function () {
|
|
|
65
68
|
globalThis[ENDPOINT_KEY] = this;
|
|
66
69
|
};
|
|
67
70
|
VerdocsEndpoint.getDefault = function () {
|
|
71
|
+
if (!globalThis[ENDPOINT_KEY]) {
|
|
72
|
+
globalThis[ENDPOINT_KEY] = new VerdocsEndpoint();
|
|
73
|
+
window.console.debug('[JS_SDK] Created default endpoint', globalThis[ENDPOINT_KEY]);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
window.console.debug('[JS SDK] Re-using existing endpoint', globalThis[ENDPOINT_KEY]);
|
|
77
|
+
}
|
|
68
78
|
return globalThis[ENDPOINT_KEY];
|
|
69
79
|
};
|
|
70
80
|
/**
|
|
@@ -289,10 +299,3 @@ var VerdocsEndpoint = /** @class */ (function () {
|
|
|
289
299
|
return VerdocsEndpoint;
|
|
290
300
|
}());
|
|
291
301
|
export { VerdocsEndpoint };
|
|
292
|
-
// @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
|
|
293
|
-
// Also see globalThis for comments about why we're doing this in the first place.
|
|
294
|
-
var ENDPOINT_KEY = Symbol.for('verdocs-default-endpoint');
|
|
295
|
-
if (!globalThis[ENDPOINT_KEY]) {
|
|
296
|
-
globalThis[ENDPOINT_KEY] = new VerdocsEndpoint();
|
|
297
|
-
window.console.debug('[JS_SDK] Created default endpoint', globalThis[ENDPOINT_KEY]);
|
|
298
|
-
}
|