backend-manager 2.3.18 → 2.3.19
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
|
@@ -33,12 +33,14 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
33
33
|
options = options || {};
|
|
34
34
|
options.initialize = typeof options.initialize === 'undefined' ? true : options.initialize;
|
|
35
35
|
options.setupFunctions = typeof options.setupFunctions === 'undefined' ? true : options.setupFunctions;
|
|
36
|
+
options.setupFunctionsLegacy = typeof options.setupFunctionsLegacy === 'undefined' ? true : options.setupFunctionsLegacy;
|
|
36
37
|
options.initializeLocalStorage = typeof options.initializeLocalStorage === 'undefined' ? false : options.initializeLocalStorage;
|
|
37
38
|
options.sentry = typeof options.sentry === 'undefined' ? true : options.sentry;
|
|
38
39
|
options.reportErrorsInDev = typeof options.reportErrorsInDev === 'undefined' ? false : options.reportErrorsInDev;
|
|
39
40
|
options.firebaseConfig = options.firebaseConfig;
|
|
40
41
|
options.useFirebaseLogger = typeof options.useFirebaseLogger === 'undefined' ? true : options.useFirebaseLogger;
|
|
41
|
-
options.serviceAccountPath = typeof options.serviceAccountPath === 'undefined' ? 'service-account.json' : options.serviceAccountPath;
|
|
42
|
+
// options.serviceAccountPath = typeof options.serviceAccountPath === 'undefined' ? 'service-account.json' : options.serviceAccountPath;
|
|
43
|
+
options.serviceAccountPath = typeof options.serviceAccountPath === 'undefined' ? undefined : options.serviceAccountPath;
|
|
42
44
|
options.uniqueAppName = options.uniqueAppName || undefined;
|
|
43
45
|
options.assistant = options.assistant || {};
|
|
44
46
|
// options.assistant.optionsLogString = options.assistant.optionsLogString || undefined;
|
|
@@ -113,13 +115,16 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
113
115
|
if (self.options.initialize) {
|
|
114
116
|
// console.log('Initializing:', self.project);
|
|
115
117
|
try {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
if (options.serviceAccountPath && options.uniqueAppName) {
|
|
119
|
+
self.libraries.initializedAdmin = self.libraries.admin.initializeApp({
|
|
120
|
+
credential: self.libraries.admin.credential.cert(
|
|
121
|
+
require(path.resolve(self.cwd, options.serviceAccountPath))
|
|
122
|
+
),
|
|
123
|
+
databaseURL: self.project.databaseURL,
|
|
124
|
+
}, options.uniqueAppName);
|
|
125
|
+
} else {
|
|
126
|
+
self.libraries.initializedAdmin = self.libraries.admin.initializeApp();
|
|
127
|
+
}
|
|
123
128
|
} catch (e) {
|
|
124
129
|
console.error('Failed to call .initializeApp()', e);
|
|
125
130
|
}
|
|
@@ -142,127 +147,174 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
142
147
|
});
|
|
143
148
|
});
|
|
144
149
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
if (options.setupFunctionsLegacy) {
|
|
151
|
+
exporter.bm_signUpHandler =
|
|
152
|
+
self.libraries.functions
|
|
153
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
154
|
+
.https.onRequest(async (req, res) => {
|
|
155
|
+
const Module = require(`${core}/actions/sign-up-handler.js`);
|
|
156
|
+
Module.init(self, { req: req, res: res, });
|
|
151
157
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
return self._preProcess(Module)
|
|
159
|
+
.then(r => Module.main())
|
|
160
|
+
.catch(e => {
|
|
161
|
+
self.assistant.error(e, {environment: 'production'});
|
|
162
|
+
return res.status(500).send(e.message);
|
|
163
|
+
});
|
|
157
164
|
});
|
|
158
|
-
});
|
|
159
165
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
// Admin
|
|
167
|
+
exporter.bm_createPost =
|
|
168
|
+
self.libraries.functions
|
|
169
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
170
|
+
.https.onRequest(async (req, res) => {
|
|
171
|
+
const Module = require(`${core}/admin/create-post.js`);
|
|
172
|
+
Module.init(self, { req: req, res: res, });
|
|
167
173
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
return self._preProcess(Module)
|
|
175
|
+
.then(r => Module.main())
|
|
176
|
+
.catch(e => {
|
|
177
|
+
self.assistant.error(e, {environment: 'production'});
|
|
178
|
+
return res.status(500).send(e.message);
|
|
179
|
+
});
|
|
173
180
|
});
|
|
174
|
-
});
|
|
175
181
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
exporter.bm_firestoreWrite =
|
|
183
|
+
self.libraries.functions
|
|
184
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
185
|
+
.https.onRequest(async (req, res) => {
|
|
186
|
+
const Module = require(`${core}/admin/firestore-write.js`);
|
|
187
|
+
Module.init(self, { req: req, res: res, });
|
|
182
188
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
return self._preProcess(Module)
|
|
190
|
+
.then(r => Module.main())
|
|
191
|
+
.catch(e => {
|
|
192
|
+
self.assistant.error(e, {environment: 'production'});
|
|
193
|
+
return res.status(500).send(e.message);
|
|
194
|
+
});
|
|
188
195
|
});
|
|
189
|
-
});
|
|
190
196
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
exporter.bm_getStats =
|
|
198
|
+
self.libraries.functions
|
|
199
|
+
.runWith({memory: '256MB', timeoutSeconds: 420})
|
|
200
|
+
.https.onRequest(async (req, res) => {
|
|
201
|
+
const Module = require(`${core}/admin/get-stats.js`);
|
|
202
|
+
Module.init(self, { req: req, res: res, });
|
|
197
203
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
return self._preProcess(Module)
|
|
205
|
+
.then(r => Module.main())
|
|
206
|
+
.catch(e => {
|
|
207
|
+
self.assistant.error(e, {environment: 'production'});
|
|
208
|
+
return res.status(500).send(e.message);
|
|
209
|
+
});
|
|
203
210
|
});
|
|
204
|
-
});
|
|
205
211
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
exporter.bm_sendNotification =
|
|
213
|
+
self.libraries.functions
|
|
214
|
+
.runWith({memory: '1GB', timeoutSeconds: 420})
|
|
215
|
+
.https.onRequest(async (req, res) => {
|
|
216
|
+
const Module = require(`${core}/admin/send-notification.js`);
|
|
217
|
+
Module.init(self, { req: req, res: res, });
|
|
212
218
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
219
|
+
return self._preProcess(Module)
|
|
220
|
+
.then(r => Module.main())
|
|
221
|
+
.catch(e => {
|
|
222
|
+
self.assistant.error(e, {environment: 'production'});
|
|
223
|
+
return res.status(500).send(e.message);
|
|
224
|
+
});
|
|
218
225
|
});
|
|
219
|
-
});
|
|
220
226
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
+
exporter.bm_query =
|
|
228
|
+
self.libraries.functions
|
|
229
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
230
|
+
.https.onRequest(async (req, res) => {
|
|
231
|
+
const Module = require(`${core}/admin/query.js`);
|
|
232
|
+
Module.init(self, { req: req, res: res, });
|
|
227
233
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
234
|
+
return self._preProcess(Module)
|
|
235
|
+
.then(r => Module.main())
|
|
236
|
+
.catch(e => {
|
|
237
|
+
self.assistant.error(e, {environment: 'production'});
|
|
238
|
+
return res.status(500).send(e.message);
|
|
239
|
+
});
|
|
233
240
|
});
|
|
234
|
-
});
|
|
235
241
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
exporter.bm_createPostHandler =
|
|
243
|
+
self.libraries.functions
|
|
244
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
245
|
+
.https.onRequest(async (req, res) => {
|
|
246
|
+
const Module = require(`${core}/actions/create-post-handler.js`);
|
|
247
|
+
Module.init(self, { req: req, res: res, });
|
|
242
248
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
return self._preProcess(Module)
|
|
250
|
+
.then(r => Module.main())
|
|
251
|
+
.catch(e => {
|
|
252
|
+
self.assistant.error(e, {environment: 'production'});
|
|
253
|
+
return res.status(500).send(e.message);
|
|
254
|
+
});
|
|
248
255
|
});
|
|
249
|
-
});
|
|
250
256
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
exporter.bm_generateUuid =
|
|
258
|
+
self.libraries.functions
|
|
259
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
260
|
+
.https.onRequest(async (req, res) => {
|
|
261
|
+
const Module = require(`${core}/actions/generate-uuid.js`);
|
|
262
|
+
Module.init(self, { req: req, res: res, });
|
|
257
263
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
264
|
+
return self._preProcess(Module)
|
|
265
|
+
.then(r => Module.main())
|
|
266
|
+
.catch(e => {
|
|
267
|
+
self.assistant.error(e, {environment: 'production'});
|
|
268
|
+
return res.status(500).send(e.message);
|
|
269
|
+
});
|
|
263
270
|
});
|
|
264
|
-
});
|
|
265
271
|
|
|
272
|
+
// Test
|
|
273
|
+
exporter.bm_test_authenticate =
|
|
274
|
+
self.libraries.functions
|
|
275
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
276
|
+
.https.onRequest(async (req, res) => {
|
|
277
|
+
const Module = require(`${test}/authenticate.js`);
|
|
278
|
+
Module.init(self, { req: req, res: res, });
|
|
279
|
+
|
|
280
|
+
return self._preProcess(Module)
|
|
281
|
+
.then(r => Module.main())
|
|
282
|
+
.catch(e => {
|
|
283
|
+
self.assistant.error(e, {environment: 'production'});
|
|
284
|
+
return res.status(500).send(e.message);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
exporter.bm_test_createTestAccounts =
|
|
289
|
+
self.libraries.functions
|
|
290
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
291
|
+
.https.onRequest(async (req, res) => {
|
|
292
|
+
const Module = require(`${test}/create-test-accounts.js`);
|
|
293
|
+
Module.init(self, { req: req, res: res, });
|
|
294
|
+
|
|
295
|
+
return self._preProcess(Module)
|
|
296
|
+
.then(r => Module.main())
|
|
297
|
+
.catch(e => {
|
|
298
|
+
self.assistant.error(e, {environment: 'production'});
|
|
299
|
+
return res.status(500).send(e.message);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
exporter.bm_test_webhook =
|
|
304
|
+
self.libraries.functions
|
|
305
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
306
|
+
.https.onRequest(async (req, res) => {
|
|
307
|
+
const Module = require(`${test}/webhook.js`);
|
|
308
|
+
Module.init(self, { req: req, res: res, });
|
|
309
|
+
|
|
310
|
+
return self._preProcess(Module)
|
|
311
|
+
.then(r => Module.main())
|
|
312
|
+
.catch(e => {
|
|
313
|
+
self.assistant.error(e, {environment: 'production'});
|
|
314
|
+
return res.status(500).send(e.message);
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
266
318
|
|
|
267
319
|
// Events
|
|
268
320
|
exporter.bm_authOnCreate =
|
|
@@ -308,53 +360,6 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
308
360
|
self.assistant.error(e, {environment: 'production'});
|
|
309
361
|
});
|
|
310
362
|
});
|
|
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
363
|
}
|
|
359
364
|
|
|
360
365
|
// Set dotenv
|