backend-manager 3.0.1 → 3.0.3

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/CHANGELOG.md CHANGED
@@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
28
28
  - Updated `uuid` from `8.3.2` --> `9.0.0`
29
29
 
30
30
  - Removed `backend-assistant` dependency and moved to custom library within this module at `./src/manager/helpers/assistant.js`
31
+ - Removed `require('firebase-functions/lib/logger/compat')`
31
32
  - Changed default for `options.setupFunctionsLegacy` from `true` --> `false`
32
33
  - Updated geolocation and client data retrieval to new format:
33
34
  #### New Way
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -57,7 +57,7 @@
57
57
  "npm-api": "^1.0.1",
58
58
  "paypal-server-api": "^1.0.3",
59
59
  "pushid": "^1.0.0",
60
- "resolve-account": "^1.0.2",
60
+ "resolve-account": "^1.0.3",
61
61
  "semver": "^7.5.4",
62
62
  "shortid": "^2.2.16",
63
63
  "sizeitup": "^1.0.7",
@@ -27,6 +27,7 @@ Module.prototype.main = function () {
27
27
  return new Promise(async function(resolve, reject) {
28
28
  const functions = self.libraries.functions;
29
29
  const admin = self.libraries.admin;
30
+ const storage = self.Manager.storage({ temporary: true, name: 'rate-limiting' });
30
31
 
31
32
  assistant.log(`Request: ${user.uid}`, user, context, { environment: 'production' });
32
33
 
@@ -35,7 +36,7 @@ Module.prototype.main = function () {
35
36
  const oneHour = 60 * 60 * 1000; // One hour in milliseconds
36
37
 
37
38
  // Get current rate-limiting data
38
- const rateLimitingData = await self.Manager.storage({ name: 'rate-limiting' }).get(`ipRateLimits.${ipAddress}`);
39
+ const rateLimitingData = storage.get(`ipRateLimits.${ipAddress}`);
39
40
  const count = get(rateLimitingData, 'count', 0);
40
41
  const lastTime = get(rateLimitingData, 'lastTime', 0);
41
42
 
@@ -48,7 +49,7 @@ Module.prototype.main = function () {
48
49
  }
49
50
 
50
51
  // Update rate-limiting data
51
- await self.Manager.storage({ name: 'rate-limiting' }).set(`ipRateLimits.${ipAddress}`, { count: count + 1, lastTime: currentTime });
52
+ storage.set(`ipRateLimits.${ipAddress}`, { count: count + 1, lastTime: currentTime });
52
53
 
53
54
  const existingAccount = await admin.firestore().doc(`users/${user.uid}`)
54
55
  .get()
@@ -99,7 +99,7 @@ function User(Manager, settings, options) {
99
99
  userAgent: _.get(settings, 'activity.client.userAgent', defaults ? '' : null),
100
100
  language: _.get(settings, 'activity.client.language', defaults ? '' : null),
101
101
  platform: _.get(settings, 'activity.client.platform', defaults ? '' : null),
102
- mobile: _.get(settings, 'activity.client.mobile', defaults ? '' : null),
102
+ mobile: _.get(settings, 'activity.client.mobile', defaults ? null : null),
103
103
  },
104
104
  },
105
105
  api: {
@@ -97,9 +97,10 @@ Manager.prototype.init = function (exporter, options) {
97
97
  process.env.ENVIRONMENT = !process.env.ENVIRONMENT ? self.assistant.meta.environment : process.env.ENVIRONMENT;
98
98
 
99
99
  // Use the working Firebase logger that they disabled for whatever reason
100
- // if (process.env.GCLOUD_PROJECT && self.assistant.meta.environment !== 'development' && options.useFirebaseLogger) {
101
- // require('firebase-functions/lib/logger/compat');
102
- // }
100
+ if (process.env.GCLOUD_PROJECT && self.assistant.meta.environment !== 'development' && options.useFirebaseLogger) {
101
+ // require('firebase-functions/lib/logger/compat'); // Old way
102
+ require('firebase-functions/logger/compat'); // firebase-functions@4 and above?
103
+ }
103
104
 
104
105
  // Handle dev environments
105
106
  if (self.assistant.meta.environment === 'development') {