nestjs-firebase-admin 0.0.3 → 0.0.5

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.
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Observable } from 'rxjs';
3
+ import Admin from 'firebase-admin';
3
4
  import type { App } from 'firebase-admin/app';
4
5
  import type { Agent } from 'node:http';
5
6
  import type { AdminModuleOptions } from './types';
@@ -10,7 +11,8 @@ export declare class AdminService {
10
11
  deleteApp(app: App): Promise<void>;
11
12
  get getApps(): App[];
12
13
  get getApp(): App;
13
- initializeApp(): App;
14
+ admin(): typeof Admin;
14
15
  initializeAppObservable<T = App>(): Observable<App>;
15
16
  get appRef(): App;
17
+ initializeApp(): App;
16
18
  }
@@ -37,8 +37,8 @@ let AdminService = class AdminService {
37
37
  get getApp() {
38
38
  return (0, app_1.getApp)();
39
39
  }
40
- initializeApp() {
41
- return (0, app_1.initializeApp)(Object.assign(Object.assign({}, this.options), { credential: firebase_admin_1.default.credential.cert(this.options.credential) }));
40
+ admin() {
41
+ return firebase_admin_1.default;
42
42
  }
43
43
  initializeAppObservable() {
44
44
  return new rxjs_1.Observable(subscriber => {
@@ -55,8 +55,39 @@ let AdminService = class AdminService {
55
55
  get appRef() {
56
56
  return this.initializeApp();
57
57
  }
58
+ initializeApp() {
59
+ let options = {};
60
+ if ('credential' in this.options) {
61
+ options.credential = this.options.credential;
62
+ }
63
+ if ('databaseAuthVariableOverride' in this.options) {
64
+ options.databaseAuthVariableOverride = this.options.databaseAuthVariableOverride;
65
+ }
66
+ if ('databaseURL' in this.options) {
67
+ options.databaseURL = this.options.databaseURL;
68
+ }
69
+ if ('httpAgent' in this.options) {
70
+ options.httpAgent = this.options.httpAgent;
71
+ }
72
+ if ('projectId' in this.options) {
73
+ options.projectId = this.options.projectId;
74
+ }
75
+ if ('serviceAccountId' in this.options) {
76
+ options.serviceAccountId = this.options.serviceAccountId;
77
+ }
78
+ if ('storageBucket' in this.options) {
79
+ options.storageBucket = this.options.storageBucket;
80
+ }
81
+ if (options) {
82
+ return firebase_admin_1.default.initializeApp(Object.assign(Object.assign({}, options), { credential: firebase_admin_1.default.credential.cert(this.options.credential) }));
83
+ }
84
+ return firebase_admin_1.default.initializeApp({
85
+ credential: firebase_admin_1.default.credential.cert(this.options.credential)
86
+ });
87
+ }
58
88
  };
59
89
  AdminService = __decorate([
90
+ (0, common_1.Injectable)(),
60
91
  __param(0, (0, common_1.Inject)(admin_constants_1.FIREBASE_ADMIN_INSTANCE_TOKEN)),
61
92
  __metadata("design:paramtypes", [Object])
62
93
  ], AdminService);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-firebase-admin",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Firebase Admin SDK for Nestjs",
5
5
  "author": "Hebert Cisco",
6
6
  "license": "MIT",