backend-manager 5.0.15 → 5.0.17
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
|
@@ -78,8 +78,8 @@ Middleware.prototype.run = function (libPath, options) {
|
|
|
78
78
|
const strippedUrl = stripUrl(url);
|
|
79
79
|
|
|
80
80
|
// Log
|
|
81
|
-
assistant.log(`Middleware.process(): Request (${geolocation.ip} @ ${geolocation.country}, ${geolocation.region}, ${geolocation.city}) [${method} > ${strippedUrl}]`,
|
|
82
|
-
assistant.log(`Middleware.process(): Headers`,
|
|
81
|
+
assistant.log(`Middleware.process(): Request (${geolocation.ip} @ ${geolocation.country}, ${geolocation.region}, ${geolocation.city}) [${method} > ${strippedUrl}]`, safeStringify(data));
|
|
82
|
+
assistant.log(`Middleware.process(): Headers`, safeStringify(headers));
|
|
83
83
|
|
|
84
84
|
// Set paths
|
|
85
85
|
const routesDir = path.resolve(options.routesDir, libPath.replace('.js', ''));
|
|
@@ -128,7 +128,7 @@ Middleware.prototype.run = function (libPath, options) {
|
|
|
128
128
|
|
|
129
129
|
// Log working user
|
|
130
130
|
const workingUser = assistant.getUser();
|
|
131
|
-
assistant.log(`Middleware.process(): User (${workingUser.auth.uid}, ${workingUser.auth.email}, ${workingUser.plan.id}=${workingUser.plan.status}):`,
|
|
131
|
+
assistant.log(`Middleware.process(): User (${workingUser.auth.uid}, ${workingUser.auth.email}, ${workingUser.plan.id}=${workingUser.plan.status}):`, safeStringify(workingUser));
|
|
132
132
|
|
|
133
133
|
// Setup analytics
|
|
134
134
|
if (options.setupAnalytics) {
|
|
@@ -173,12 +173,12 @@ Middleware.prototype.run = function (libPath, options) {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
// Log
|
|
176
|
-
assistant.log(`Middleware.process(): Resolved settings with schema=${options.schema}`,
|
|
176
|
+
assistant.log(`Middleware.process(): Resolved settings with schema=${options.schema}`, safeStringify(assistant.settings));
|
|
177
177
|
|
|
178
178
|
// Log multipart files if they exist
|
|
179
179
|
const files = assistant.request.multipartData.files || {};
|
|
180
180
|
if (files) {
|
|
181
|
-
assistant.log(`Middleware.process(): Multipart files`,
|
|
181
|
+
assistant.log(`Middleware.process(): Multipart files`, safeStringify(files));
|
|
182
182
|
}
|
|
183
183
|
} else {
|
|
184
184
|
assistant.settings = data;
|
|
@@ -218,4 +218,17 @@ function stripUrl(url) {
|
|
|
218
218
|
return `${newUrl.hostname}${newUrl.pathname}`.replace(/\/$/, '');
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
// Helper to safely stringify objects by truncating long strings (like base64)
|
|
222
|
+
function safeStringify(obj, maxLength = 100) {
|
|
223
|
+
const truncate = (value) => {
|
|
224
|
+
if (typeof value === 'string' && value.length > maxLength) {
|
|
225
|
+
return `${value.substring(0, maxLength)}... [truncated ${value.length - maxLength} chars]`;
|
|
226
|
+
}
|
|
227
|
+
return value;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const truncated = JSON.parse(JSON.stringify(obj, (key, value) => truncate(value)));
|
|
231
|
+
return JSON.stringify(truncated);
|
|
232
|
+
}
|
|
233
|
+
|
|
221
234
|
module.exports = Middleware;
|
|
@@ -44,7 +44,7 @@ Usage.prototype.init = function (assistant, options) {
|
|
|
44
44
|
options.key = typeof options.key === 'undefined' ? undefined : options.key;
|
|
45
45
|
options.unauthenticatedMode = typeof options.unauthenticatedMode === 'undefined' ? 'firestore' : options.unauthenticatedMode;
|
|
46
46
|
options.whitelistKeys = options.whitelistKeys || [];
|
|
47
|
-
options.log = typeof options.log === 'undefined' ?
|
|
47
|
+
options.log = typeof options.log === 'undefined' ? assistant.isDevelopment() : options.log;
|
|
48
48
|
|
|
49
49
|
// Check for required options
|
|
50
50
|
if (!assistant) {
|
|
@@ -148,7 +148,7 @@ Usage.prototype.validate = function (name, options) {
|
|
|
148
148
|
// Set options
|
|
149
149
|
options = options || {};
|
|
150
150
|
options.useCaptchaResponse = typeof options.useCaptchaResponse === 'undefined' ? true : options.useCaptchaResponse;
|
|
151
|
-
options.log = typeof options.log === 'undefined' ?
|
|
151
|
+
options.log = typeof options.log === 'undefined' ? assistant.isDevelopment() : options.log;
|
|
152
152
|
options.throw = typeof options.throw === 'undefined' ? false : options.throw;
|
|
153
153
|
|
|
154
154
|
// Check for required options
|
|
@@ -157,7 +157,7 @@ Usage.prototype.validate = function (name, options) {
|
|
|
157
157
|
|
|
158
158
|
// Log (independent of options.log because this is important)
|
|
159
159
|
if (options.log) {
|
|
160
|
-
assistant.log(`Usage.validate(): Checking ${period}/${allowed} for ${name}...`);
|
|
160
|
+
assistant.log(`Usage.validate(): Checking ${period}/${allowed} for ${name} (${self.key})...`);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
// Reject function
|