backend-manager 3.2.138 → 3.2.140

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.138",
3
+ "version": "3.2.140",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -7,13 +7,15 @@ function Module() {
7
7
 
8
8
  Module.prototype.main = function () {
9
9
  const self = this;
10
+
11
+ // Set shortcuts
10
12
  const Manager = self.Manager;
11
13
  const Api = self.Api;
12
14
  const assistant = self.assistant;
13
15
  const payload = self.payload;
14
16
 
15
17
  return new Promise(async function(resolve, reject) {
16
-
18
+ // Check for admin
17
19
  if (!payload.user.roles.admin) {
18
20
  return reject(assistant.errorify(`Admin required.`, {code: 401}));
19
21
  }
@@ -7,6 +7,8 @@ function Module() {
7
7
 
8
8
  Module.prototype.main = function () {
9
9
  const self = this;
10
+
11
+ // Set shortcuts
10
12
  const Manager = self.Manager;
11
13
  const Api = self.Api;
12
14
  const assistant = self.assistant;
@@ -24,7 +26,7 @@ Module.prototype.main = function () {
24
26
  }
25
27
 
26
28
  // Load the hook
27
- const hook = loadHook(assistant, payload);
29
+ const hook = self.loadHook(payload);
28
30
 
29
31
  // Run the hook
30
32
  try {
@@ -50,8 +52,15 @@ Module.prototype.main = function () {
50
52
  });
51
53
  };
52
54
 
53
- function loadHook(assistant, payload) {
54
- const Manager = assistant.Manager;
55
+ Module.prototype.loadHook = function () {
56
+ const self = this;
57
+
58
+ // Set shortcuts
59
+ const Manager = self.Manager;
60
+ const assistant = self.assistant;
61
+ const payload = self.payload;
62
+
63
+ // Set paths
55
64
  const paths = [
56
65
  `${Manager.rootDirectory}/functions/core/${payload.data.payload.path}`,
57
66
  `${Manager.cwd}/${payload.data.payload.path}`,
@@ -9,6 +9,8 @@ function Module() {
9
9
 
10
10
  Module.prototype.main = function () {
11
11
  const self = this;
12
+
13
+ // Set shortcuts
12
14
  const Manager = self.Manager;
13
15
  const Api = self.Api;
14
16
  const assistant = self.assistant;
@@ -246,7 +246,7 @@ Module.prototype.resolveCommand = function (command) {
246
246
  }
247
247
 
248
248
  // Check local path
249
- const resolvedPath = resolveApiPath(command);
249
+ const resolvedPath = self.resolveApiPath(command);
250
250
 
251
251
  // if (!command || command === 'error:error') {
252
252
  if (!resolvedPath) {
@@ -325,7 +325,17 @@ function resolveBasePath(basePath, command) {
325
325
  return resolvedPath;
326
326
  };
327
327
 
328
- function resolveApiPath(command) {
328
+ Module.prototype.resolveApiPath = function (command) {
329
+ const self = this;
330
+
331
+ // Set shortcuts
332
+ const Manager = self.Manager;
333
+ const libraries = self.libraries;
334
+ const assistant = self.assistant;
335
+ const req = self.req;
336
+ const res = self.res;
337
+
338
+ // Set paths
329
339
  const projectBasePath = path.join(Manager.cwd, 'routes/api');
330
340
  const localBasePath = './api/';
331
341
 
@@ -7,7 +7,7 @@ const PROMPT = `
7
7
  Company: {name}: {description}
8
8
  Current Date: {date}
9
9
  Instructions: {prompt}
10
- Topic Suggestion: {suggestion}
10
+ Topic Suggestions: {suggestion}
11
11
  `
12
12
 
13
13
  function Module() {
@@ -28,6 +28,9 @@ Module.prototype.main = function (assistant, context) {
28
28
  // Get settings
29
29
  const settings = Manager.config.ghostii;
30
30
 
31
+ // Set post ID
32
+ self.postId = moment().unix();
33
+
31
34
  // Log
32
35
  assistant.log(`Settings`, settings);
33
36
 
@@ -247,23 +250,6 @@ Module.prototype.uploadPost = function (article) {
247
250
  const context = self.context;
248
251
 
249
252
  return new Promise(async function(resolve, reject) {
250
- // request.body.command = 'admin:create-post';
251
- // request.body.payload = {
252
- // title: data.payload.postTitle,
253
- // url: data.formatted.path,
254
- // excerpt: data.payload.postExcerpt,
255
- // headerImageURL: data.payload.postHeaderImageUrl,
256
- // body: data.payload.postBody,
257
- // id: self.postId++,
258
- // author: 'alex',
259
- // // affiliate: '',
260
- // // tags: 'tag, tag2, tag3',
261
- // // categories: 'marketing, business',
262
- // githubUser: app.github.user,
263
- // githubRepo: app.github.repo,
264
- // }
265
-
266
-
267
253
  // Fetch URL
268
254
  fetch(`${self.appObject.server}/bm_api`, {
269
255
  method: 'post',
@@ -272,7 +258,7 @@ Module.prototype.uploadPost = function (article) {
272
258
  response: 'json',
273
259
  body: {
274
260
  backendManagerKey: Manager.config.backend_manager.key,
275
- command: '',
261
+ command: 'admin:create-post',
276
262
  payload: {
277
263
  title: article.title,
278
264
  url: article.title, // This is formatted on the bm_api endpoint
@@ -17,6 +17,8 @@ function Middleware(m, req, res) {
17
17
 
18
18
  Middleware.prototype.run = function (libPath, options) {
19
19
  const self = this;
20
+
21
+ // Set shortcuts
20
22
  const Manager = self.Manager;
21
23
  const req = self.req;
22
24
  const res = self.res;