backend-manager 2.3.17 → 2.3.20
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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const _ = require('lodash')
|
|
2
|
+
|
|
3
|
+
function Module() {
|
|
4
|
+
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Module.prototype.main = function () {
|
|
8
|
+
const self = this;
|
|
9
|
+
const Manager = self.Manager;
|
|
10
|
+
const Api = self.Api;
|
|
11
|
+
const assistant = self.assistant;
|
|
12
|
+
const payload = self.payload;
|
|
13
|
+
|
|
14
|
+
return new Promise(async function(resolve, reject) {
|
|
15
|
+
self.Api.resolveUser({adminRequired: true})
|
|
16
|
+
.then(async (user) => {
|
|
17
|
+
// return resolve({data: {success: true}});
|
|
18
|
+
// return reject(assistant.errorManager(`Failed to delete user: ${e}`, {code: 400, sentry: false, send: false, log: false}).error)
|
|
19
|
+
console.log('---payload', payload);
|
|
20
|
+
})
|
|
21
|
+
.catch(e => {
|
|
22
|
+
return reject(e);
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
module.exports = Module;
|
package/src/manager/index.js
CHANGED
|
@@ -32,8 +32,10 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
32
32
|
// Set options defaults
|
|
33
33
|
options = options || {};
|
|
34
34
|
options.initialize = typeof options.initialize === 'undefined' ? true : options.initialize;
|
|
35
|
+
options.log = typeof options.log === 'undefined' ? false : options.log;
|
|
35
36
|
options.setupFunctions = typeof options.setupFunctions === 'undefined' ? true : options.setupFunctions;
|
|
36
|
-
options.
|
|
37
|
+
options.setupFunctionsLegacy = typeof options.setupFunctionsLegacy === 'undefined' ? true : options.setupFunctionsLegacy;
|
|
38
|
+
options.initializeLocalStorage = typeof options.initializeLocalStorage === 'undefined' ? false : options.initializeLocalStorage;
|
|
37
39
|
options.sentry = typeof options.sentry === 'undefined' ? true : options.sentry;
|
|
38
40
|
options.reportErrorsInDev = typeof options.reportErrorsInDev === 'undefined' ? false : options.reportErrorsInDev;
|
|
39
41
|
options.firebaseConfig = options.firebaseConfig;
|
|
@@ -85,6 +87,10 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
85
87
|
require('firebase-functions/lib/logger/compat');
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
if (options.log) {
|
|
91
|
+
self.assistant.log('process.env', process.env, {environment: 'production'})
|
|
92
|
+
}
|
|
93
|
+
|
|
88
94
|
// Setup sentry
|
|
89
95
|
if (self.options.sentry) {
|
|
90
96
|
const sentryRelease = `${get(self.config, 'app.id') || self.project.projectId}@${self.package.version}`;
|
|
@@ -112,14 +118,19 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
112
118
|
// Setup options features
|
|
113
119
|
if (self.options.initialize) {
|
|
114
120
|
// console.log('Initializing:', self.project);
|
|
121
|
+
// console.log('----process.env.GOOGLE_APPLICATION_CREDENTIALS', process.env.GOOGLE_APPLICATION_CREDENTIALS);
|
|
115
122
|
try {
|
|
116
|
-
// console.log('
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
// console.log('---process.env.GOOGLE_APPLICATION_CREDENTIALS', process.env.GOOGLE_APPLICATION_CREDENTIALS);
|
|
124
|
+
if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
125
|
+
self.libraries.initializedAdmin = self.libraries.admin.initializeApp();
|
|
126
|
+
} else {
|
|
127
|
+
self.libraries.initializedAdmin = self.libraries.admin.initializeApp({
|
|
128
|
+
credential: self.libraries.admin.credential.cert(
|
|
129
|
+
require(path.resolve(self.cwd, options.serviceAccountPath))
|
|
130
|
+
),
|
|
131
|
+
databaseURL: self.project.databaseURL,
|
|
132
|
+
}, options.uniqueAppName);
|
|
133
|
+
}
|
|
123
134
|
} catch (e) {
|
|
124
135
|
console.error('Failed to call .initializeApp()', e);
|
|
125
136
|
}
|
|
@@ -142,127 +153,174 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
142
153
|
});
|
|
143
154
|
});
|
|
144
155
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
156
|
+
if (options.setupFunctionsLegacy) {
|
|
157
|
+
exporter.bm_signUpHandler =
|
|
158
|
+
self.libraries.functions
|
|
159
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
160
|
+
.https.onRequest(async (req, res) => {
|
|
161
|
+
const Module = require(`${core}/actions/sign-up-handler.js`);
|
|
162
|
+
Module.init(self, { req: req, res: res, });
|
|
151
163
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
return self._preProcess(Module)
|
|
165
|
+
.then(r => Module.main())
|
|
166
|
+
.catch(e => {
|
|
167
|
+
self.assistant.error(e, {environment: 'production'});
|
|
168
|
+
return res.status(500).send(e.message);
|
|
169
|
+
});
|
|
157
170
|
});
|
|
158
|
-
});
|
|
159
171
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
172
|
+
// Admin
|
|
173
|
+
exporter.bm_createPost =
|
|
174
|
+
self.libraries.functions
|
|
175
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
176
|
+
.https.onRequest(async (req, res) => {
|
|
177
|
+
const Module = require(`${core}/admin/create-post.js`);
|
|
178
|
+
Module.init(self, { req: req, res: res, });
|
|
167
179
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
180
|
+
return self._preProcess(Module)
|
|
181
|
+
.then(r => Module.main())
|
|
182
|
+
.catch(e => {
|
|
183
|
+
self.assistant.error(e, {environment: 'production'});
|
|
184
|
+
return res.status(500).send(e.message);
|
|
185
|
+
});
|
|
173
186
|
});
|
|
174
|
-
});
|
|
175
187
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
exporter.bm_firestoreWrite =
|
|
189
|
+
self.libraries.functions
|
|
190
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
191
|
+
.https.onRequest(async (req, res) => {
|
|
192
|
+
const Module = require(`${core}/admin/firestore-write.js`);
|
|
193
|
+
Module.init(self, { req: req, res: res, });
|
|
182
194
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
195
|
+
return self._preProcess(Module)
|
|
196
|
+
.then(r => Module.main())
|
|
197
|
+
.catch(e => {
|
|
198
|
+
self.assistant.error(e, {environment: 'production'});
|
|
199
|
+
return res.status(500).send(e.message);
|
|
200
|
+
});
|
|
188
201
|
});
|
|
189
|
-
});
|
|
190
202
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
203
|
+
exporter.bm_getStats =
|
|
204
|
+
self.libraries.functions
|
|
205
|
+
.runWith({memory: '256MB', timeoutSeconds: 420})
|
|
206
|
+
.https.onRequest(async (req, res) => {
|
|
207
|
+
const Module = require(`${core}/admin/get-stats.js`);
|
|
208
|
+
Module.init(self, { req: req, res: res, });
|
|
197
209
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
210
|
+
return self._preProcess(Module)
|
|
211
|
+
.then(r => Module.main())
|
|
212
|
+
.catch(e => {
|
|
213
|
+
self.assistant.error(e, {environment: 'production'});
|
|
214
|
+
return res.status(500).send(e.message);
|
|
215
|
+
});
|
|
203
216
|
});
|
|
204
|
-
});
|
|
205
217
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
218
|
+
exporter.bm_sendNotification =
|
|
219
|
+
self.libraries.functions
|
|
220
|
+
.runWith({memory: '1GB', timeoutSeconds: 420})
|
|
221
|
+
.https.onRequest(async (req, res) => {
|
|
222
|
+
const Module = require(`${core}/admin/send-notification.js`);
|
|
223
|
+
Module.init(self, { req: req, res: res, });
|
|
212
224
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
225
|
+
return self._preProcess(Module)
|
|
226
|
+
.then(r => Module.main())
|
|
227
|
+
.catch(e => {
|
|
228
|
+
self.assistant.error(e, {environment: 'production'});
|
|
229
|
+
return res.status(500).send(e.message);
|
|
230
|
+
});
|
|
218
231
|
});
|
|
219
|
-
});
|
|
220
232
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
233
|
+
exporter.bm_query =
|
|
234
|
+
self.libraries.functions
|
|
235
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
236
|
+
.https.onRequest(async (req, res) => {
|
|
237
|
+
const Module = require(`${core}/admin/query.js`);
|
|
238
|
+
Module.init(self, { req: req, res: res, });
|
|
227
239
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
240
|
+
return self._preProcess(Module)
|
|
241
|
+
.then(r => Module.main())
|
|
242
|
+
.catch(e => {
|
|
243
|
+
self.assistant.error(e, {environment: 'production'});
|
|
244
|
+
return res.status(500).send(e.message);
|
|
245
|
+
});
|
|
233
246
|
});
|
|
234
|
-
});
|
|
235
247
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
248
|
+
exporter.bm_createPostHandler =
|
|
249
|
+
self.libraries.functions
|
|
250
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
251
|
+
.https.onRequest(async (req, res) => {
|
|
252
|
+
const Module = require(`${core}/actions/create-post-handler.js`);
|
|
253
|
+
Module.init(self, { req: req, res: res, });
|
|
242
254
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
255
|
+
return self._preProcess(Module)
|
|
256
|
+
.then(r => Module.main())
|
|
257
|
+
.catch(e => {
|
|
258
|
+
self.assistant.error(e, {environment: 'production'});
|
|
259
|
+
return res.status(500).send(e.message);
|
|
260
|
+
});
|
|
248
261
|
});
|
|
249
|
-
});
|
|
250
262
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
263
|
+
exporter.bm_generateUuid =
|
|
264
|
+
self.libraries.functions
|
|
265
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
266
|
+
.https.onRequest(async (req, res) => {
|
|
267
|
+
const Module = require(`${core}/actions/generate-uuid.js`);
|
|
268
|
+
Module.init(self, { req: req, res: res, });
|
|
257
269
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
270
|
+
return self._preProcess(Module)
|
|
271
|
+
.then(r => Module.main())
|
|
272
|
+
.catch(e => {
|
|
273
|
+
self.assistant.error(e, {environment: 'production'});
|
|
274
|
+
return res.status(500).send(e.message);
|
|
275
|
+
});
|
|
263
276
|
});
|
|
264
|
-
});
|
|
265
277
|
|
|
278
|
+
// Test
|
|
279
|
+
exporter.bm_test_authenticate =
|
|
280
|
+
self.libraries.functions
|
|
281
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
282
|
+
.https.onRequest(async (req, res) => {
|
|
283
|
+
const Module = require(`${test}/authenticate.js`);
|
|
284
|
+
Module.init(self, { req: req, res: res, });
|
|
285
|
+
|
|
286
|
+
return self._preProcess(Module)
|
|
287
|
+
.then(r => Module.main())
|
|
288
|
+
.catch(e => {
|
|
289
|
+
self.assistant.error(e, {environment: 'production'});
|
|
290
|
+
return res.status(500).send(e.message);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
exporter.bm_test_createTestAccounts =
|
|
295
|
+
self.libraries.functions
|
|
296
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
297
|
+
.https.onRequest(async (req, res) => {
|
|
298
|
+
const Module = require(`${test}/create-test-accounts.js`);
|
|
299
|
+
Module.init(self, { req: req, res: res, });
|
|
300
|
+
|
|
301
|
+
return self._preProcess(Module)
|
|
302
|
+
.then(r => Module.main())
|
|
303
|
+
.catch(e => {
|
|
304
|
+
self.assistant.error(e, {environment: 'production'});
|
|
305
|
+
return res.status(500).send(e.message);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
exporter.bm_test_webhook =
|
|
310
|
+
self.libraries.functions
|
|
311
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
312
|
+
.https.onRequest(async (req, res) => {
|
|
313
|
+
const Module = require(`${test}/webhook.js`);
|
|
314
|
+
Module.init(self, { req: req, res: res, });
|
|
315
|
+
|
|
316
|
+
return self._preProcess(Module)
|
|
317
|
+
.then(r => Module.main())
|
|
318
|
+
.catch(e => {
|
|
319
|
+
self.assistant.error(e, {environment: 'production'});
|
|
320
|
+
return res.status(500).send(e.message);
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
}
|
|
266
324
|
|
|
267
325
|
// Events
|
|
268
326
|
exporter.bm_authOnCreate =
|
|
@@ -308,53 +366,6 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
308
366
|
self.assistant.error(e, {environment: 'production'});
|
|
309
367
|
});
|
|
310
368
|
});
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// Test
|
|
314
|
-
exporter.bm_test_authenticate =
|
|
315
|
-
self.libraries.functions
|
|
316
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
317
|
-
.https.onRequest(async (req, res) => {
|
|
318
|
-
const Module = require(`${test}/authenticate.js`);
|
|
319
|
-
Module.init(self, { req: req, res: res, });
|
|
320
|
-
|
|
321
|
-
return self._preProcess(Module)
|
|
322
|
-
.then(r => Module.main())
|
|
323
|
-
.catch(e => {
|
|
324
|
-
self.assistant.error(e, {environment: 'production'});
|
|
325
|
-
return res.status(500).send(e.message);
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
exporter.bm_test_createTestAccounts =
|
|
330
|
-
self.libraries.functions
|
|
331
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
332
|
-
.https.onRequest(async (req, res) => {
|
|
333
|
-
const Module = require(`${test}/create-test-accounts.js`);
|
|
334
|
-
Module.init(self, { req: req, res: res, });
|
|
335
|
-
|
|
336
|
-
return self._preProcess(Module)
|
|
337
|
-
.then(r => Module.main())
|
|
338
|
-
.catch(e => {
|
|
339
|
-
self.assistant.error(e, {environment: 'production'});
|
|
340
|
-
return res.status(500).send(e.message);
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
exporter.bm_test_webhook =
|
|
345
|
-
self.libraries.functions
|
|
346
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
347
|
-
.https.onRequest(async (req, res) => {
|
|
348
|
-
const Module = require(`${test}/webhook.js`);
|
|
349
|
-
Module.init(self, { req: req, res: res, });
|
|
350
|
-
|
|
351
|
-
return self._preProcess(Module)
|
|
352
|
-
.then(r => Module.main())
|
|
353
|
-
.catch(e => {
|
|
354
|
-
self.assistant.error(e, {environment: 'production'});
|
|
355
|
-
return res.status(500).send(e.message);
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
369
|
}
|
|
359
370
|
|
|
360
371
|
// Set dotenv
|
|
@@ -365,7 +376,7 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
365
376
|
}
|
|
366
377
|
|
|
367
378
|
// Setup LocalDatabase
|
|
368
|
-
if (options.
|
|
379
|
+
if (options.initializeLocalStorage) {
|
|
369
380
|
self.storage();
|
|
370
381
|
}
|
|
371
382
|
|