backend-manager 3.2.41 → 3.2.43

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.41",
3
+ "version": "3.2.43",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -401,7 +401,7 @@ BackendAssistant.prototype.errorify = function (e, options) {
401
401
  self.Manager.libraries.sentry.captureException(newError);
402
402
  }
403
403
 
404
- // Quit and respond to the request
404
+ // Quit and respond to the request only if the assistant has a res (it sometimes does not, like in auth().onCreate() triggers)
405
405
  if (options.send && res?.status) {
406
406
  let sendable = newError?.stack && options.stack
407
407
  ? newError?.stack
@@ -422,9 +422,6 @@ BackendAssistant.prototype.errorify = function (e, options) {
422
422
  .send(sendable);
423
423
  }
424
424
 
425
- // return {
426
- // error: newError,
427
- // }
428
425
  return newError;
429
426
  }
430
427
 
@@ -527,19 +524,17 @@ function _attachHeaderProperties(self, options, error) {
527
524
  const req = self.ref.req;
528
525
  const res = self.ref.res;
529
526
 
530
- // Attach properties
531
- try {
527
+ // Attach properties if this assistant has a res (it sometimes does not, like in auth().onCreate() triggers)
528
+ if (res?.header && res?.get) {
532
529
  res.header('bm-properties', JSON.stringify(headers));
533
- } catch (e) {
534
- self.warn('Error attaching properties to header', e);
535
- }
536
530
 
537
- // Add bm-properties to Access-Control-Expose-Headers
538
- const existingExposed = res.get('Access-Control-Expose-Headers') || '';
539
- const newExposed = `${existingExposed}, bm-properties`.replace(/^, /, '');
531
+ // Add bm-properties to Access-Control-Expose-Headers
532
+ const existingExposed = res.get('Access-Control-Expose-Headers') || '';
533
+ const newExposed = `${existingExposed}, bm-properties`.replace(/^, /, '');
540
534
 
541
- if (!existingExposed.match(/bm-properties/i)) {
542
- res.header('Access-Control-Expose-Headers', newExposed);
535
+ if (!existingExposed.match(/bm-properties/i)) {
536
+ res.header('Access-Control-Expose-Headers', newExposed);
537
+ }
543
538
  }
544
539
 
545
540
  // Attach properties
@@ -99,11 +99,10 @@ OpenAI.prototype.request = function (options) {
99
99
 
100
100
  // Load content
101
101
  if (input.path) {
102
- if (!jetpack.exists(input.path)) {
102
+ const exists = jetpack.exists(input.path);
103
+ if (!exists) {
103
104
  return new Error(`Path ${input.path} not found`);
104
- }
105
-
106
- if (jetpack.isDirectory(input.path)) {
105
+ } else if (exists === 'dir') {
107
106
  return new Error(`Path ${input.path} is a directory`);
108
107
  }
109
108