backend-manager 3.0.40 → 3.0.41
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/package.json
CHANGED
|
@@ -341,7 +341,9 @@ BackendAssistant.prototype.errorManager = function(e, options) {
|
|
|
341
341
|
options.sentry = typeof options.sentry === 'undefined' ? true : options.sentry;
|
|
342
342
|
options.send = typeof options.send === 'undefined' ? true : options.send;
|
|
343
343
|
|
|
344
|
-
const newError = e instanceof Error
|
|
344
|
+
const newError = e instanceof Error
|
|
345
|
+
? e
|
|
346
|
+
: new Error(stringify(e));
|
|
345
347
|
|
|
346
348
|
// Attach properties
|
|
347
349
|
Object.keys(options)
|
|
@@ -370,6 +372,14 @@ BackendAssistant.prototype.errorManager = function(e, options) {
|
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
|
|
375
|
+
function stringify(e) {
|
|
376
|
+
if (typeof e === 'string') {
|
|
377
|
+
return e;
|
|
378
|
+
} else {
|
|
379
|
+
return JSON.stringify(e);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
373
383
|
|
|
374
384
|
BackendAssistant.prototype.authenticate = async function (options) {
|
|
375
385
|
const self = this;
|
|
@@ -105,9 +105,6 @@ Usage.prototype.init = function (assistant, options) {
|
|
|
105
105
|
self.log(`Usage.init(): Got app data`, self.app);
|
|
106
106
|
self.log(`Usage.init(): Got user`, self.user);
|
|
107
107
|
|
|
108
|
-
// Resolve with the user to get their current plan limits
|
|
109
|
-
// If there is no user, go forward with their IP and make them a basic plan user
|
|
110
|
-
|
|
111
108
|
// Set initialized to true
|
|
112
109
|
self.initialized = true;
|
|
113
110
|
|
|
@@ -127,8 +124,8 @@ Usage.prototype.validate = function (path, options) {
|
|
|
127
124
|
options.useCaptchaResponse = typeof options.useCaptchaResponse === 'undefined' ? true : options.useCaptchaResponse;
|
|
128
125
|
|
|
129
126
|
// Check for required options
|
|
130
|
-
const period =
|
|
131
|
-
const allowed =
|
|
127
|
+
const period = self.getUsage(path)
|
|
128
|
+
const allowed = self.getLimits(path);
|
|
132
129
|
|
|
133
130
|
// Log
|
|
134
131
|
self.log(`Usage.validate(): Checking ${period}/${allowed} for ${path}...`);
|
|
@@ -214,6 +211,22 @@ Usage.prototype.set = function (path, value) {
|
|
|
214
211
|
return self;
|
|
215
212
|
};
|
|
216
213
|
|
|
214
|
+
Usage.prototype.getUsage = function (path) {
|
|
215
|
+
const self = this;
|
|
216
|
+
const Manager = self.Manager;
|
|
217
|
+
const assistant = self.assistant;
|
|
218
|
+
|
|
219
|
+
return _.get(self.user, `usage.${path}.period`, 0);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
Usage.prototype.getLimit = function (path) {
|
|
223
|
+
const self = this;
|
|
224
|
+
const Manager = self.Manager;
|
|
225
|
+
const assistant = self.assistant;
|
|
226
|
+
|
|
227
|
+
return _.get(self.app, `products.${self.options.app}-${self.user.plan.id}.limits.${path}`, 0);
|
|
228
|
+
};
|
|
229
|
+
|
|
217
230
|
Usage.prototype.update = function () {
|
|
218
231
|
const self = this;
|
|
219
232
|
|