backend-manager 3.0.2 → 3.0.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -69,4 +69,4 @@
69
69
  "wonderful-log": "^1.0.5",
70
70
  "yargs": "^17.7.2"
71
71
  }
72
- }
72
+ }
@@ -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()
@@ -23,6 +23,8 @@ Module.prototype.main = function () {
23
23
  const context = self.context;
24
24
 
25
25
  return new Promise(async function(resolve, reject) {
26
+ const functions = self.libraries.functions;
27
+ const admin = self.libraries.admin;
26
28
 
27
29
  assistant.log(`Request: ${user.uid}`, user, context, {environment: 'production'});
28
30
 
@@ -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') {