nestjs-firebase-admin 0.5.9 → 0.6.1

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/.nojekyll ADDED
File without changes
package/README.md CHANGED
@@ -2,7 +2,15 @@
2
2
  <img src="art/logo.png" alt="nestjs-firebase-admin logo" width="200">
3
3
  </p>
4
4
 
5
+ <h1 align="center">nestjs-firebase-admin</h1>
6
+
7
+ <p align="center">
8
+ Firebase Admin SDK module for <a href="https://nestjs.com/">NestJS</a> — injectable services for Auth, Firestore, Realtime Database, and Cloud Messaging.
9
+ </p>
10
+
5
11
  <p align="center">
12
+ <a href="https://www.npmjs.com/package/nestjs-firebase-admin"><img src="https://img.shields.io/npm/v/nestjs-firebase-admin.svg" alt="npm version"></a>
13
+ <a href="https://www.npmjs.com/package/nestjs-firebase-admin"><img src="https://img.shields.io/npm/dm/nestjs-firebase-admin.svg" alt="npm downloads"></a>
6
14
  <a href="https://codecov.io/gh/hebertcisco/nestjs-firebase-admin">
7
15
  <img src="https://codecov.io/gh/hebertcisco/nestjs-firebase-admin/branch/main/graph/badge.svg?token=N0IW1UNNIP" alt="codecov">
8
16
  </a>
@@ -12,90 +20,139 @@
12
20
  <a href="https://github.com/hebertcisco/nestjs-firebase-admin/actions/workflows/coverage.yml">
13
21
  <img src="https://github.com/hebertcisco/nestjs-firebase-admin/actions/workflows/coverage.yml/badge.svg" alt="Running Code Coverage">
14
22
  </a>
15
- <img src="https://img.shields.io/badge/TypeScript-007ACC?style=flat&logo=typescript&logoColor=white" alt="TypeScript">
16
- <img src="https://img.shields.io/badge/Nestjs-ea2845?style=flat&logo=nestjs&logoColor=white" alt="Nestjs">
17
- <img src="https://img.shields.io/badge/VS_Code-0078D4?style=flat&logo=visual%20studio%20code&logoColor=white" alt="VS Code">
18
- <img src="https://img.shields.io/badge/github%20actions-%232671E5.svg?style=flat&logo=githubactions&logoColor=white" alt="GitHub Actions">
19
23
  </p>
20
24
 
21
- > Firebase Admin SDK for NestJS :fire:
25
+ ## Features
22
26
 
23
- ## Requirements
24
-
25
- - **Node.js**: >= 20
26
- - **NPM**: >= 10
27
- - **NestJS**: >= 7.0.0
27
+ - **AdminService** — Firebase app initialization and lifecycle management
28
+ - **AuthService** — Create, update, delete users; verify ID tokens; manage custom claims
29
+ - **FirestoreService** Typed CRUD, collection queries, batch writes, transactions
30
+ - **DatabaseService** Realtime Database read, write, push, update, remove, and listeners
31
+ - **MessagingService** Send to device tokens, topics, and conditions; manage subscriptions
32
+ - Sync (`register`) and async (`registerAsync`) module registration
33
+ - Compatible with **NestJS 7 – 11** and **Firebase Admin 13+**
34
+ - TypeScript-first with full type support
28
35
 
29
36
  ## Installation
30
37
 
31
- Install the package using `yarn`, `npm`, or `pnpm`:
32
-
33
38
  ```bash
34
- # yarn
35
- yarn add nestjs-firebase-admin
36
- ```
37
-
38
- ```bash
39
- # npm
40
39
  npm i nestjs-firebase-admin --save
41
40
  ```
42
41
 
42
+ <details>
43
+ <summary>yarn / pnpm</summary>
44
+
43
45
  ```bash
44
- # pnpm
45
- pnpm add nestjs-firebase-admin --save
46
+ yarn add nestjs-firebase-admin
46
47
  ```
47
48
 
48
- ## Testing
49
-
50
- To run tests, use the following commands:
51
-
52
- ### Unit Tests
53
-
54
49
  ```bash
55
- npm test
50
+ pnpm add nestjs-firebase-admin
56
51
  ```
57
52
 
58
- ### Coverage Tests
53
+ </details>
54
+
55
+ ## Quick start
56
+
57
+ Import `AdminModule` in your root or feature module:
58
+
59
+ ```ts
60
+ import { Module } from '@nestjs/common';
61
+ import { AdminModule } from 'nestjs-firebase-admin';
62
+
63
+ @Module({
64
+ imports: [
65
+ AdminModule.register({
66
+ credential: {
67
+ projectId: 'my-project-id',
68
+ clientEmail: 'my-client-email',
69
+ privateKey: 'my-private-key',
70
+ },
71
+ databaseURL: 'https://my-project-id.firebaseio.com',
72
+ }),
73
+ ],
74
+ })
75
+ export class AppModule {}
76
+ ```
59
77
 
60
- ```bash
61
- npm run test:cov
78
+ ### Async configuration
79
+
80
+ Use `registerAsync` to load credentials from `ConfigService` or any other provider:
81
+
82
+ ```ts
83
+ import { Module } from '@nestjs/common';
84
+ import { ConfigService } from '@nestjs/config';
85
+ import { AdminModule } from 'nestjs-firebase-admin';
86
+
87
+ @Module({
88
+ imports: [
89
+ AdminModule.registerAsync({
90
+ inject: [ConfigService],
91
+ useFactory: (config: ConfigService) => ({
92
+ credential: {
93
+ projectId: config.get('FIREBASE_PROJECT_ID'),
94
+ clientEmail: config.get('FIREBASE_CLIENT_EMAIL'),
95
+ privateKey: config.get('FIREBASE_PRIVATE_KEY'),
96
+ },
97
+ databaseURL: config.get('FIREBASE_DATABASE_URL'),
98
+ }),
99
+ }),
100
+ ],
101
+ })
102
+ export class AppModule {}
62
103
  ```
63
104
 
64
- ### Watch Mode Tests
105
+ ## Usage examples
65
106
 
66
- ```bash
67
- npm run test:watch
68
- ```
107
+ Once `AdminModule` is imported, inject any service:
69
108
 
70
- ### Debug Tests
109
+ ```ts
110
+ import { Injectable } from '@nestjs/common';
111
+ import { AuthService, FirestoreService } from 'nestjs-firebase-admin';
71
112
 
72
- ```bash
73
- npm run test:debug
74
- ```
113
+ @Injectable()
114
+ export class UsersService {
115
+ constructor(
116
+ private readonly auth: AuthService,
117
+ private readonly firestore: FirestoreService,
118
+ ) {}
75
119
 
76
- ## Available Scripts
120
+ async createUser(email: string, password: string) {
121
+ const user = await this.auth.createUser({ email, password });
122
+ await this.firestore.set(`users/${user.uid}`, { email, createdAt: new Date() });
123
+ return user;
124
+ }
77
125
 
78
- The available scripts in `package.json` include:
126
+ async getUser(uid: string) {
127
+ return this.firestore.get(`users/${uid}`);
128
+ }
129
+ }
130
+ ```
79
131
 
80
- - **Build**: `npm run build`
81
- - **Lint**: `npm run lint`
82
- - **Format**: `npm run format`
83
- - **Release**: `npm run release`
132
+ ## Requirements
84
133
 
85
- ## Contributing
134
+ | Dependency | Version |
135
+ |-----------|---------|
136
+ | Node.js | >= 20 |
137
+ | NestJS | >= 7.0.0 |
138
+ | firebase-admin | >= 13.0.0 |
86
139
 
87
- Contributions, issues, and feature requests are welcome!<br />Feel free to check the [issues page](https://github.com/hebertcisco/nestjs-firebase-admin/issues).
140
+ ## Documentation
88
141
 
89
- ## Show Your Support
142
+ Full documentation is available at **[hebertcisco.github.io/nestjs-firebase-admin](https://hebertcisco.github.io/nestjs-firebase-admin/)**.
90
143
 
91
- Give a ⭐️ if this project helped you!
144
+ - [Getting Started](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/getting-started)
145
+ - [Admin Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/admin-service)
146
+ - [Auth Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/auth-service)
147
+ - [Firestore Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/firestore-service)
148
+ - [Database Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/database-service)
149
+ - [Messaging Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/messaging-service)
150
+ - [Testing](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/testing)
92
151
 
93
- Or buy the author a coffee 🙌🏾
152
+ ## Contributing
94
153
 
95
- <a href="https://www.buymeacoffee.com/hebertcisco">
96
- <img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=hebertcisco&button_colour=FFDD00&font_colour=000000&font_family=Inter&outline_colour=000000&coffee_colour=ffffff" />
97
- </a>
154
+ Contributions, issues, and feature requests are welcome! Check the [issues page](https://github.com/hebertcisco/nestjs-firebase-admin/issues) or read the [contributing guide](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/contributing).
98
155
 
99
- ## 📝 License
156
+ ## License
100
157
 
101
- This project is under the [MIT](LICENSE) license.
158
+ [MIT](LICENSE)
package/_coverpage.md ADDED
@@ -0,0 +1,13 @@
1
+ ![logo](art/logo.png ':size=120')
2
+
3
+ # nestjs-firebase-admin
4
+
5
+ > Firebase Admin SDK module for NestJS
6
+
7
+ - Injectable services for Auth, Firestore, Database, and Messaging
8
+ - Sync and async module registration
9
+ - TypeScript-first with full type support
10
+ - Compatible with NestJS 7 through 11
11
+
12
+ [Get Started](docs/getting-started.md)
13
+ [GitHub](https://github.com/hebertcisco/nestjs-firebase-admin)
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './modules/admin/admin.module';
2
2
  export * from './modules/admin/services/admin.service';
3
+ export * from './modules/admin/services/auth.service';
3
4
  export * from './modules/admin/services/database.service';
4
5
  export * from './modules/admin/services/messaging.service';
5
6
  export * from './modules/admin/services/firestore.service';
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./modules/admin/admin.module"), exports);
18
18
  __exportStar(require("./modules/admin/services/admin.service"), exports);
19
+ __exportStar(require("./modules/admin/services/auth.service"), exports);
19
20
  __exportStar(require("./modules/admin/services/database.service"), exports);
20
21
  __exportStar(require("./modules/admin/services/messaging.service"), exports);
21
22
  __exportStar(require("./modules/admin/services/firestore.service"), exports);
@@ -69,15 +69,10 @@ let AdminModule = AdminModule_1 = class AdminModule {
69
69
  };
70
70
  }
71
71
  static registerAsync(options) {
72
- if (!options.useFactory) {
73
- throw new Error('useFactory is required in registerAsync options');
72
+ if (!options.useFactory && !options.useExisting && !options.useClass) {
73
+ throw new Error('One of useFactory, useExisting, or useClass must be provided in AdminModuleAsyncOptions');
74
74
  }
75
75
  const providers = [
76
- {
77
- provide: admin_constants_1.ADMIN_MODULE_OPTIONS,
78
- useFactory: options.useFactory,
79
- inject: options.inject || [],
80
- },
81
76
  admin_service_1.AdminService,
82
77
  database_service_1.DatabaseService,
83
78
  messaging_service_1.MessagingService,
@@ -89,6 +84,11 @@ let AdminModule = AdminModule_1 = class AdminModule {
89
84
  },
90
85
  ];
91
86
  if (options.useFactory) {
87
+ providers.push({
88
+ provide: admin_constants_1.ADMIN_MODULE_OPTIONS,
89
+ useFactory: options.useFactory,
90
+ inject: options.inject || [],
91
+ });
92
92
  const factory = options.useFactory;
93
93
  providers.push({
94
94
  provide: admin_constants_1.FIREBASE_ADMIN_INSTANCE_TOKEN,
@@ -105,12 +105,14 @@ let AdminModule = AdminModule_1 = class AdminModule {
105
105
  });
106
106
  }
107
107
  else if (options.useExisting) {
108
+ providers.push({
109
+ provide: admin_constants_1.ADMIN_MODULE_OPTIONS,
110
+ useFactory: (optionsFactory) => __awaiter(this, void 0, void 0, function* () { return optionsFactory.createAdminOptions(); }),
111
+ inject: [options.useExisting],
112
+ });
108
113
  providers.push({
109
114
  provide: admin_constants_1.FIREBASE_ADMIN_INSTANCE_TOKEN,
110
- useFactory: (optionsFactory) => __awaiter(this, void 0, void 0, function* () {
111
- const config = yield optionsFactory.createAdminOptions();
112
- return config;
113
- }),
115
+ useFactory: (optionsFactory) => __awaiter(this, void 0, void 0, function* () { return optionsFactory.createAdminOptions(); }),
114
116
  inject: [options.useExisting],
115
117
  });
116
118
  providers.push({
@@ -127,12 +129,14 @@ let AdminModule = AdminModule_1 = class AdminModule {
127
129
  provide: options.useClass,
128
130
  useClass: options.useClass,
129
131
  });
132
+ providers.push({
133
+ provide: admin_constants_1.ADMIN_MODULE_OPTIONS,
134
+ useFactory: (optionsFactory) => __awaiter(this, void 0, void 0, function* () { return optionsFactory.createAdminOptions(); }),
135
+ inject: [options.useClass],
136
+ });
130
137
  providers.push({
131
138
  provide: admin_constants_1.FIREBASE_ADMIN_INSTANCE_TOKEN,
132
- useFactory: (optionsFactory) => __awaiter(this, void 0, void 0, function* () {
133
- const config = yield optionsFactory.createAdminOptions();
134
- return config;
135
- }),
139
+ useFactory: (optionsFactory) => __awaiter(this, void 0, void 0, function* () { return optionsFactory.createAdminOptions(); }),
136
140
  inject: [options.useClass],
137
141
  });
138
142
  providers.push({
@@ -144,9 +148,6 @@ let AdminModule = AdminModule_1 = class AdminModule {
144
148
  inject: [options.useClass],
145
149
  });
146
150
  }
147
- else {
148
- throw new Error('One of useFactory, useExisting, or useClass must be provided in AdminModuleAsyncOptions');
149
- }
150
151
  return {
151
152
  module: AdminModule_1,
152
153
  imports: options.imports || [],
@@ -39,7 +39,7 @@ let MessagingService = class MessagingService {
39
39
  sendToDevices(tokens, payload) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  const message = Object.assign({ tokens }, payload);
42
- const response = yield this.messaging.sendMulticast(message);
42
+ const response = yield this.messaging.sendEachForMulticast(message);
43
43
  return response;
44
44
  });
45
45
  }
@@ -55,18 +55,20 @@ If you need asynchronous configuration, use the `registerAsync` method:
55
55
 
56
56
  ```ts
57
57
  import { Module } from '@nestjs/common';
58
+ import { ConfigService } from '@nestjs/config';
58
59
  import { AdminModule } from 'nestjs-firebase-admin';
59
60
 
60
61
  @Module({
61
62
  imports: [
62
63
  AdminModule.registerAsync({
63
- useFactory: async () => ({
64
+ inject: [ConfigService],
65
+ useFactory: async (config: ConfigService) => ({
64
66
  credential: {
65
- projectId: 'my-project-id',
66
- clientEmail: 'my-client-email',
67
- privateKey: 'my-private-key',
67
+ projectId: config.get('FIREBASE_PROJECT_ID'),
68
+ clientEmail: config.get('FIREBASE_CLIENT_EMAIL'),
69
+ privateKey: config.get('FIREBASE_PRIVATE_KEY'),
68
70
  },
69
- databaseURL: 'https://my-project-id.firebaseio.com',
71
+ databaseURL: config.get('FIREBASE_DATABASE_URL'),
70
72
  }),
71
73
  }),
72
74
  ],
@@ -74,9 +76,18 @@ import { AdminModule } from 'nestjs-firebase-admin';
74
76
  export class AppModule {}
75
77
  ```
76
78
 
79
+ You can also use `useClass` or `useExisting` for more advanced scenarios:
80
+
81
+ ```ts
82
+ AdminModule.registerAsync({
83
+ useClass: FirebaseConfigService,
84
+ })
85
+ ```
86
+
77
87
  ## Next Steps
78
88
 
79
89
  - Learn about the [Admin Service](services/admin-service.md)
90
+ - Manage users with the [Auth Service](services/auth-service.md)
80
91
  - Explore the [Database Service](services/database-service.md)
81
92
  - Check out the [Firestore Service](services/firestore-service.md)
82
93
  - Discover the [Messaging Service](services/messaging-service.md)
@@ -56,6 +56,9 @@ export class FirebaseService {
56
56
  | `deleteApp(app)` | Deletes a Firebase app instance | [Delete App](https://firebase.google.com/docs/reference/admin/node/firebase-admin.app#deleteapp) |
57
57
  | `applicationDefault(httpAgent?)` | Gets default credentials | [Application Default](https://firebase.google.com/docs/reference/admin/node/firebase-admin.credential#applicationdefault) |
58
58
  | `admin()` | Gets the Firebase Admin SDK instance | [Admin SDK](https://firebase.google.com/docs/admin/setup) |
59
+ | `appRef` | Gets the initialized app instance reference | [Initialize App](https://firebase.google.com/docs/reference/admin/node/firebase-admin.app#initializeapp) |
60
+ | `initializeApp()` | Returns the initialized app instance | [Initialize App](https://firebase.google.com/docs/reference/admin/node/firebase-admin.app#initializeapp) |
61
+ | `initializeAppObservable()` | Creates an Observable that emits the app instance | [Initialize App](https://firebase.google.com/docs/reference/admin/node/firebase-admin.app#initializeapp) |
59
62
 
60
63
  ## Configuration
61
64
 
@@ -5,10 +5,9 @@ The `MessagingService` provides a clean and type-safe interface for sending mess
5
5
  ## Features
6
6
 
7
7
  - Send messages to individual devices
8
- - Send multicast messages to multiple devices
9
- - Topic messaging
10
- - Conditional messaging
11
- - Message customization
8
+ - Send messages to multiple devices
9
+ - Topic messaging and subscription management
10
+ - Message customization per platform (Android, iOS, Web)
12
11
  - TypeScript type support
13
12
 
14
13
  ## Usage Example
@@ -23,8 +22,7 @@ export class NotificationService {
23
22
 
24
23
  // Send a message to a single device
25
24
  async sendToDevice(deviceToken: string, title: string, body: string) {
26
- await this.messagingService.send({
27
- token: deviceToken,
25
+ return this.messagingService.sendToDevice(deviceToken, {
28
26
  notification: {
29
27
  title,
30
28
  body,
@@ -34,8 +32,7 @@ export class NotificationService {
34
32
 
35
33
  // Send a message to multiple devices
36
34
  async sendToDevices(deviceTokens: string[], title: string, body: string) {
37
- await this.messagingService.sendMulticast({
38
- tokens: deviceTokens,
35
+ return this.messagingService.sendToDevices(deviceTokens, {
39
36
  notification: {
40
37
  title,
41
38
  body,
@@ -45,8 +42,7 @@ export class NotificationService {
45
42
 
46
43
  // Send a message to a topic
47
44
  async sendToTopic(topic: string, title: string, body: string) {
48
- await this.messagingService.send({
49
- topic,
45
+ return this.messagingService.sendToTopic(topic, {
50
46
  notification: {
51
47
  title,
52
48
  body,
@@ -56,12 +52,12 @@ export class NotificationService {
56
52
 
57
53
  // Subscribe devices to a topic
58
54
  async subscribeToTopic(topic: string, deviceTokens: string[]) {
59
- await this.messagingService.subscribeToTopic(deviceTokens, topic);
55
+ return this.messagingService.subscribeToTopic(deviceTokens, topic);
60
56
  }
61
57
 
62
58
  // Unsubscribe devices from a topic
63
59
  async unsubscribeFromTopic(topic: string, deviceTokens: string[]) {
64
- await this.messagingService.unsubscribeFromTopic(deviceTokens, topic);
60
+ return this.messagingService.unsubscribeFromTopic(deviceTokens, topic);
65
61
  }
66
62
  }
67
63
  ```
@@ -70,8 +66,9 @@ export class NotificationService {
70
66
 
71
67
  | Method | Description | Documentation |
72
68
  |--------|-------------|---------------|
73
- | `send(message)` | Sends a message to a device or topic | [Send Messages](https://firebase.google.com/docs/cloud-messaging/send-message) |
74
- | `sendMulticast(message)` | Sends a message to multiple devices | [Send Multicast](https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-multiple-devices) |
69
+ | `sendToDevice(token, payload)` | Sends a message to a single device | [Send Messages](https://firebase.google.com/docs/cloud-messaging/send-message) |
70
+ | `sendToDevices(tokens, payload)` | Sends a message to multiple devices | [Send Multicast](https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-multiple-devices) |
71
+ | `sendToTopic(topic, payload)` | Sends a message to a topic | [Topic Messaging](https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-topics) |
75
72
  | `subscribeToTopic(tokens, topic)` | Subscribes devices to a topic | [Topic Management](https://firebase.google.com/docs/cloud-messaging/manage-topics) |
76
73
  | `unsubscribeFromTopic(tokens, topic)` | Unsubscribes devices from a topic | [Topic Management](https://firebase.google.com/docs/cloud-messaging/manage-topics) |
77
74
 
@@ -82,6 +79,6 @@ The service supports various message types:
82
79
  - **Notification Messages**: Simple messages with title and body
83
80
  - **Data Messages**: Custom key-value pairs
84
81
  - **Combined Messages**: Both notification and data
85
- - **Android Messages**: Android-specific configurations
86
- - **APNS Messages**: iOS-specific configurations
87
- - **Webpush Messages**: Web-specific configurations
82
+ - **Android Messages**: Android-specific configurations (priority, TTL, channel)
83
+ - **APNS Messages**: iOS-specific configurations (sound, badge, alert)
84
+ - **Webpush Messages**: Web-specific configurations (headers, icons, actions)
package/index.html CHANGED
@@ -1,19 +1,65 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html lang="en">
3
3
 
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
- <title>NestJS Firebase Admin</title>
6
+ <title>NestJS Firebase Admin — Firebase Admin SDK module for NestJS</title>
7
7
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
8
8
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
9
- <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
10
- <link rel="icon" type="image/png"
11
- href="https://raw.githubusercontent.com/hebertcisco/nestjs-firebase-admin/refs/heads/main/art/logo.png" />
9
+
10
+ <!-- SEO -->
12
11
  <meta name="description"
13
- content="NestJS Firebase Admin is a NestJS module that provides a simple and efficient way to integrate Firebase Admin SDK into your NestJS applications.">
14
- <meta name="keywords" content="NestJS, Firebase, Admin SDK, Module, Integration">
12
+ content="NestJS Firebase Admin is a NestJS module that wraps the Firebase Admin SDK, providing injectable services for Auth, Firestore, Realtime Database, and Cloud Messaging in your NestJS applications.">
13
+ <meta name="keywords"
14
+ content="NestJS, Firebase, Admin SDK, NestJS module, Firebase Auth, Firestore, Realtime Database, Cloud Messaging, FCM, TypeScript, Node.js, serverless, backend, nestjs-firebase-admin">
15
15
  <meta name="author" content="Hebert Cisco">
16
+ <meta name="robots" content="index, follow">
17
+ <link rel="canonical" href="https://hebertcisco.github.io/nestjs-firebase-admin/" />
18
+
19
+ <!-- Open Graph -->
20
+ <meta property="og:type" content="website" />
21
+ <meta property="og:title" content="NestJS Firebase Admin — Firebase Admin SDK module for NestJS" />
22
+ <meta property="og:description"
23
+ content="Injectable NestJS services for Firebase Auth, Firestore, Realtime Database, and Cloud Messaging. TypeScript-first with sync and async module registration." />
24
+ <meta property="og:url" content="https://hebertcisco.github.io/nestjs-firebase-admin/" />
25
+ <meta property="og:image"
26
+ content="https://raw.githubusercontent.com/hebertcisco/nestjs-firebase-admin/refs/heads/main/art/logo.png" />
27
+ <meta property="og:site_name" content="nestjs-firebase-admin" />
28
+
29
+ <!-- Twitter Card -->
30
+ <meta name="twitter:card" content="summary" />
31
+ <meta name="twitter:title" content="NestJS Firebase Admin — Firebase Admin SDK module for NestJS" />
32
+ <meta name="twitter:description"
33
+ content="Injectable NestJS services for Firebase Auth, Firestore, Realtime Database, and Cloud Messaging." />
34
+ <meta name="twitter:image"
35
+ content="https://raw.githubusercontent.com/hebertcisco/nestjs-firebase-admin/refs/heads/main/art/logo.png" />
36
+
37
+ <!-- Theme -->
16
38
  <meta name="theme-color" content="#1E2830">
39
+ <link rel="icon" type="image/png"
40
+ href="https://raw.githubusercontent.com/hebertcisco/nestjs-firebase-admin/refs/heads/main/art/logo.png" />
41
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
42
+
43
+ <!-- Structured Data (JSON-LD) -->
44
+ <script type="application/ld+json">
45
+ {
46
+ "@context": "https://schema.org",
47
+ "@type": "SoftwareSourceCode",
48
+ "name": "nestjs-firebase-admin",
49
+ "description": "NestJS module that wraps the Firebase Admin SDK, providing injectable services for Auth, Firestore, Realtime Database, and Cloud Messaging.",
50
+ "url": "https://hebertcisco.github.io/nestjs-firebase-admin/",
51
+ "codeRepository": "https://github.com/hebertcisco/nestjs-firebase-admin",
52
+ "programmingLanguage": "TypeScript",
53
+ "runtimePlatform": "Node.js",
54
+ "license": "https://opensource.org/licenses/MIT",
55
+ "author": {
56
+ "@type": "Person",
57
+ "name": "Hebert Cisco",
58
+ "url": "https://github.com/hebertcisco"
59
+ },
60
+ "keywords": ["NestJS", "Firebase", "Admin SDK", "Firestore", "Auth", "Cloud Messaging", "TypeScript"]
61
+ }
62
+ </script>
17
63
  </head>
18
64
 
19
65
  <body>
@@ -21,19 +67,20 @@
21
67
  <script>
22
68
  window.$docsify = {
23
69
  name: 'NestJS Firebase Admin',
70
+ nameLink: '/',
24
71
  repo: 'hebertcisco/nestjs-firebase-admin',
25
- subMaxLevel: 3,
72
+ coverpage: '_coverpage.md',
26
73
  loadSidebar: 'docs/_sidebar.md',
27
74
  auto2top: true,
28
75
  subMaxLevel: 3,
29
76
  maxLevel: 3,
30
77
  themeColor: '#1E2830',
31
78
  noCompileLinks: ['benchmarks/.*'],
79
+ externalLinkTarget: '_blank',
32
80
  search: {
33
81
  placeholder: 'Search documentation...',
34
82
  maxAge: 86400000,
35
83
  paths: 'auto',
36
- placeholder: 'Search',
37
84
  noData: 'No results found!',
38
85
  depth: 6
39
86
  },
@@ -52,9 +99,9 @@
52
99
  ]
53
100
  }
54
101
  </script>
55
- <script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
56
- <script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
57
- <script src="//cdn.jsdelivr.net/npm/docsify-pagination/dist/docsify-pagination.min.js"></script>
102
+ <script src="https://cdn.jsdelivr.net/npm/docsify@4"></script>
103
+ <script src="https://cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
104
+ <script src="https://cdn.jsdelivr.net/npm/docsify-pagination/dist/docsify-pagination.min.js"></script>
58
105
  </body>
59
106
 
60
107
  </html>
package/llms.txt ADDED
@@ -0,0 +1,68 @@
1
+ # nestjs-firebase-admin
2
+
3
+ > Firebase Admin SDK module for NestJS
4
+
5
+ nestjs-firebase-admin is a NestJS module that wraps the Firebase Admin SDK into injectable, testable services. It supports NestJS 7-11 and Firebase Admin 13+.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i nestjs-firebase-admin --save
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ts
16
+ import { Module } from '@nestjs/common';
17
+ import { AdminModule } from 'nestjs-firebase-admin';
18
+
19
+ @Module({
20
+ imports: [
21
+ AdminModule.register({
22
+ credential: {
23
+ projectId: 'my-project-id',
24
+ clientEmail: 'my-client-email',
25
+ privateKey: 'my-private-key',
26
+ },
27
+ databaseURL: 'https://my-project-id.firebaseio.com',
28
+ }),
29
+ ],
30
+ })
31
+ export class AppModule {}
32
+ ```
33
+
34
+ Use `AdminModule.registerAsync()` with `useFactory`, `useClass`, or `useExisting` for dynamic configuration (e.g. from `ConfigService`).
35
+
36
+ ## Services
37
+
38
+ After importing `AdminModule`, inject any of these services:
39
+
40
+ - **AdminService** — Firebase app initialization, lifecycle management, credential access.
41
+ - **AuthService** — User management: create, update, delete, verify ID tokens, manage custom claims.
42
+ - **DatabaseService** — Firebase Realtime Database: read, write, push, update, remove, and listen to refs.
43
+ - **FirestoreService** — Cloud Firestore: typed CRUD, collection queries, batch writes, transactions.
44
+ - **MessagingService** — Firebase Cloud Messaging: send to device tokens, topics, conditions; manage topic subscriptions.
45
+
46
+ ## Requirements
47
+
48
+ - Node.js >= 20
49
+ - NestJS >= 7.0.0
50
+ - firebase-admin >= 13.0.0
51
+
52
+ ## Links
53
+
54
+ - Docs: https://hebertcisco.github.io/nestjs-firebase-admin/
55
+ - Repository: https://github.com/hebertcisco/nestjs-firebase-admin
56
+ - npm: https://www.npmjs.com/package/nestjs-firebase-admin
57
+ - Issues: https://github.com/hebertcisco/nestjs-firebase-admin/issues
58
+
59
+ ## Detailed docs
60
+
61
+ - [Getting started](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/getting-started)
62
+ - [Admin Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/admin-service)
63
+ - [Auth Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/auth-service)
64
+ - [Database Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/database-service)
65
+ - [Firestore Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/firestore-service)
66
+ - [Messaging Service](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/messaging-service)
67
+ - [Testing](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/testing)
68
+ - [Contributing](https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/contributing)
package/package.json CHANGED
@@ -1,10 +1,25 @@
1
1
  {
2
2
  "name": "nestjs-firebase-admin",
3
- "version": "0.5.9",
3
+ "version": "0.6.1",
4
4
  "description": "Firebase Admin SDK for Nestjs",
5
- "author": "Hebert Cisco",
5
+ "author": "hebertcisco <hebertcisco@outlook.com>",
6
6
  "license": "MIT",
7
+ "homepage": "https://hebertcisco.github.io/nestjs-firebase-admin/",
7
8
  "url": "https://github.com/hebertcisco/nestjs-firebase-admin#readme",
9
+ "keywords": [
10
+ "nestjs",
11
+ "firebase",
12
+ "firebase-admin",
13
+ "nestjs-module",
14
+ "firebase-auth",
15
+ "firestore",
16
+ "realtime-database",
17
+ "cloud-messaging",
18
+ "fcm",
19
+ "typescript",
20
+ "nestjs-firebase",
21
+ "admin-sdk"
22
+ ],
8
23
  "main": "./dist/index.js",
9
24
  "types": "./dist/index.d.ts",
10
25
  "scripts": {
@@ -18,8 +33,6 @@
18
33
  "prepublish:next": "npm run build",
19
34
  "publish:next": "npm publish --access public --tag next",
20
35
  "test:e2e": "npx jest --config ./tests/jest-e2e.json --runInBand",
21
- "prerelease": "npm run build",
22
- "release": "release-it",
23
36
  "prepare": "npm run build",
24
37
  "test": "npx jest",
25
38
  "test:watch": "npx jest --watch",
@@ -30,21 +43,17 @@
30
43
  "version": "npm run format && git add -A lib",
31
44
  "postversion": "git push && git push --tags"
32
45
  },
33
- "dependencies": {
34
- "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1",
35
- "@nestjs/core": "10.4.13",
36
- "@nestjs/platform-express": "^10.4.17",
37
- "firebase-admin": "12.7.0",
38
- "nest-shared": "^5.0.6"
39
- },
40
46
  "engines": {
41
47
  "node": ">=20",
42
48
  "npm": ">=10"
43
49
  },
50
+ "dependencies": {
51
+ "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1 || ^11.0.0",
52
+ "@nestjs/core": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1 || ^11.0.0",
53
+ "firebase-admin": "^13.7.0"
54
+ },
44
55
  "devDependencies": {
45
- "@commitlint/cli": "18.6.1",
46
- "@commitlint/config-angular": "18.6.1",
47
- "@nestjs/testing": "10.4.13",
56
+ "@nestjs/testing": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1 || ^11.0.0",
48
57
  "@types/jest": "29.5.14",
49
58
  "@types/node": "20.17.9",
50
59
  "@types/supertest": "^2.0.16",
@@ -55,12 +64,9 @@
55
64
  "eslint-plugin-import": "2.31.0",
56
65
  "eslint-plugin-jest": "^28.8.0",
57
66
  "eslint-plugin-prettier": "^5.2.1",
58
- "husky": "8.0.3",
59
67
  "jest": "29.7.0",
60
- "lint-staged": "15.2.10",
61
68
  "prettier": "^3.4.2",
62
- "reflect-metadata": "0.2.2",
63
- "release-it": "^19.0.2",
69
+ "reflect-metadata": "^0.2.2",
64
70
  "rimraf": "5.0.10",
65
71
  "rxjs": "7.8.1",
66
72
  "supertest": "^7.1.0",
@@ -68,21 +74,10 @@
68
74
  "typescript": "5.7.2"
69
75
  },
70
76
  "peerDependencies": {
71
- "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1",
77
+ "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1 || ^11.0.0",
72
78
  "reflect-metadata": "^0.2.2",
73
79
  "rxjs": "^6.0.0 || ^7.0.0"
74
80
  },
75
- "lint-staged": {
76
- "*.ts": [
77
- "prettier --write"
78
- ]
79
- },
80
- "husky": {
81
- "hooks": {
82
- "commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS",
83
- "pre-commit": "lint-staged"
84
- }
85
- },
86
81
  "repository": {
87
82
  "type": "git",
88
83
  "url": "https://github.com/hebertcisco/nestjs-firebase-admin"
@@ -99,9 +94,23 @@
99
94
  "^.+\\.(t|j)s$": "ts-jest"
100
95
  },
101
96
  "collectCoverageFrom": [
102
- "**/*.(t|j)s"
97
+ "**/*.(t|j)s",
98
+ "!**/*.spec.ts",
99
+ "!**/tests/**",
100
+ "!**/mocks/**",
101
+ "!**/interfaces/index.ts",
102
+ "!**/types/index.ts",
103
+ "!index.ts"
103
104
  ],
104
105
  "coverageDirectory": "../coverage",
106
+ "coverageThreshold": {
107
+ "global": {
108
+ "statements": 85,
109
+ "branches": 65,
110
+ "functions": 92,
111
+ "lines": 95
112
+ }
113
+ },
105
114
  "testEnvironment": "node"
106
115
  }
107
116
  }
package/robots.txt ADDED
@@ -0,0 +1,4 @@
1
+ User-agent: *
2
+ Allow: /
3
+
4
+ Sitemap: https://hebertcisco.github.io/nestjs-firebase-admin/sitemap.xml
package/sitemap.xml ADDED
@@ -0,0 +1,48 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
+ <url>
4
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/</loc>
5
+ <changefreq>weekly</changefreq>
6
+ <priority>1.0</priority>
7
+ </url>
8
+ <url>
9
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/getting-started</loc>
10
+ <changefreq>weekly</changefreq>
11
+ <priority>0.9</priority>
12
+ </url>
13
+ <url>
14
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/admin-service</loc>
15
+ <changefreq>monthly</changefreq>
16
+ <priority>0.8</priority>
17
+ </url>
18
+ <url>
19
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/auth-service</loc>
20
+ <changefreq>monthly</changefreq>
21
+ <priority>0.8</priority>
22
+ </url>
23
+ <url>
24
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/database-service</loc>
25
+ <changefreq>monthly</changefreq>
26
+ <priority>0.8</priority>
27
+ </url>
28
+ <url>
29
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/firestore-service</loc>
30
+ <changefreq>monthly</changefreq>
31
+ <priority>0.8</priority>
32
+ </url>
33
+ <url>
34
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/services/messaging-service</loc>
35
+ <changefreq>monthly</changefreq>
36
+ <priority>0.8</priority>
37
+ </url>
38
+ <url>
39
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/testing</loc>
40
+ <changefreq>monthly</changefreq>
41
+ <priority>0.6</priority>
42
+ </url>
43
+ <url>
44
+ <loc>https://hebertcisco.github.io/nestjs-firebase-admin/#/docs/contributing</loc>
45
+ <changefreq>monthly</changefreq>
46
+ <priority>0.5</priority>
47
+ </url>
48
+ </urlset>