backend-manager 3.2.62 → 3.2.63

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.2.62",
3
+ "version": "3.2.63",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  "busboy": "^1.6.0",
42
42
  "chalk": "^4.1.2",
43
43
  "cors": "^2.8.5",
44
- "dotenv": "^16.4.4",
44
+ "dotenv": "^16.4.5",
45
45
  "firebase-admin": "^11.11.1",
46
46
  "firebase-functions": "^4.7.0",
47
47
  "fs-jetpack": "^5.1.0",
@@ -65,7 +65,7 @@
65
65
  "shortid": "^2.2.16",
66
66
  "sizeitup": "^1.0.7",
67
67
  "uid-generator": "^2.0.0",
68
- "ultimate-jekyll-poster": "^0.0.15",
68
+ "ultimate-jekyll-poster": "^1.0.0",
69
69
  "uuid": "^9.0.1",
70
70
  "wonderful-fetch": "^1.1.1",
71
71
  "wonderful-log": "^1.0.5",
@@ -49,18 +49,19 @@ Module.prototype.main = function () {
49
49
  }
50
50
 
51
51
  // Request indexing
52
- try {
53
- const url = get(self.Manager.config, 'brand.url');
54
- const encoded = encodeURIComponent(`${url}/sitemap.xml`);
55
-
56
- wonderfulFetch(`https://www.google.com/ping?sitemap=${encoded}`)
57
-
58
- // TODO
59
- // https://developers.google.com/search/apis/indexing-api/v3/prereqs
60
- // https://developers.google.com/search/apis/indexing-api/v3/using-api#url
61
- } catch (e) {
62
- assistant.error(`Failed to ping google: ${e}`);
63
- }
52
+ // DEPRECATED
53
+ // try {
54
+ // const url = get(self.Manager.config, 'brand.url');
55
+ // const encoded = encodeURIComponent(`${url}/sitemap.xml`);
56
+
57
+ // wonderfulFetch(`https://www.google.com/ping?sitemap=${encoded}`)
58
+
59
+ // // TODO
60
+ // // https://developers.google.com/search/apis/indexing-api/v3/prereqs
61
+ // // https://developers.google.com/search/apis/indexing-api/v3/using-api#url
62
+ // } catch (e) {
63
+ // assistant.error(`Failed to ping google: ${e}`);
64
+ // }
64
65
 
65
66
  // Save post OR commit
66
67
  await createFile(get(self.Manager.config, 'github.user'), repoInfo.user, repoInfo.name, get(self.Manager.config, 'github.key'), poster.removeDirDot(finalPost.path), finalPost.content)
@@ -1,9 +1,12 @@
1
1
  let nanoId;
2
+ let _;
2
3
 
3
4
  function Utilities(Manager) {
4
5
  const self = this;
5
6
 
6
- self.cache = null;
7
+ _ = require('lodash');
8
+
9
+ self.cache = {};
7
10
 
8
11
  self.Manager = Manager;
9
12
  }
@@ -192,17 +195,18 @@ Utilities.prototype.get = function (docPath, options) {
192
195
  const Manager = self.Manager;
193
196
  const { admin } = Manager.libraries;
194
197
 
198
+ // Set defaults
195
199
  options = options || {};
196
200
  options.maxAge = options.maxAge || (1000 * 60 * 5); // 5 minutes
197
201
  options.readTime = typeof options.readTime === 'undefined' ? null : options.readTime;
198
202
  options.log = typeof options.log === 'undefined' ? false : options.log;
199
203
  options.format = typeof options.format === 'undefined' ? 'raw' : options.format;
200
204
 
201
- self.cache = self.cache || Manager.storage({name: 'cache', temporary: true, clear: false});
202
-
203
- const item = self.cache.get(docPath).value();
205
+ // Check cache
206
+ const item = _.get(self.cache, docPath, null)
204
207
  const age = item ? Date.now() - item.time : null;
205
208
 
209
+ // Format
206
210
  function _format(doc) {
207
211
  if (options.format === 'raw') {
208
212
  return doc;
@@ -237,14 +241,15 @@ Utilities.prototype.get = function (docPath, options) {
237
241
  .then(async (doc) => {
238
242
  const data = doc.data();
239
243
 
244
+ // Set cache
240
245
  if (data) {
241
- self.cache.set(docPath, {
246
+ _.set(self.cache, docPath, {
242
247
  doc: doc,
243
248
  time: Date.now(),
244
249
  })
245
- .write();
246
250
  }
247
251
 
252
+ // Return
248
253
  return resolve(_format(doc));
249
254
  })
250
255
  .catch((e) => reject(e));