nestjs-firebase-admin 0.5.8 → 0.6.0
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 +0 -0
- package/README.md +111 -57
- package/_coverpage.md +13 -0
- package/dist/modules/admin/services/messaging.service.js +1 -1
- package/docs/getting-started.md +16 -5
- package/docs/services/admin-service.md +3 -0
- package/docs/services/messaging-service.md +14 -17
- package/docs/testing.md +1 -1
- package/index.html +59 -12
- package/llms.txt +68 -0
- package/package.json +27 -12
- package/robots.txt +4 -0
- package/sitemap.xml +48 -0
package/.nojekyll
ADDED
|
File without changes
|
package/README.md
CHANGED
|
@@ -2,103 +2,157 @@
|
|
|
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>
|
|
9
|
-
<a href="https://dl.circleci.com/status-badge/redirect/gh/hebertcisco/nestjs-firebase-admin/tree/main">
|
|
10
|
-
<img src="https://dl.circleci.com/status-badge/img/gh/hebertcisco/nestjs-firebase-admin/tree/main.svg?style=svg" alt="CircleCI">
|
|
11
|
-
</a>
|
|
12
17
|
<a href="https://github.com/hebertcisco/nestjs-firebase-admin/actions/workflows/npm-publish.yml">
|
|
13
18
|
<img src="https://github.com/hebertcisco/nestjs-firebase-admin/actions/workflows/npm-publish.yml/badge.svg" alt="Node.js build and publish package">
|
|
14
19
|
</a>
|
|
15
20
|
<a href="https://github.com/hebertcisco/nestjs-firebase-admin/actions/workflows/coverage.yml">
|
|
16
21
|
<img src="https://github.com/hebertcisco/nestjs-firebase-admin/actions/workflows/coverage.yml/badge.svg" alt="Running Code Coverage">
|
|
17
22
|
</a>
|
|
18
|
-
<img src="https://img.shields.io/badge/TypeScript-007ACC?style=flat&logo=typescript&logoColor=white" alt="TypeScript">
|
|
19
|
-
<img src="https://img.shields.io/badge/Nestjs-ea2845?style=flat&logo=nestjs&logoColor=white" alt="Nestjs">
|
|
20
|
-
<img src="https://img.shields.io/badge/VS_Code-0078D4?style=flat&logo=visual%20studio%20code&logoColor=white" alt="VS Code">
|
|
21
|
-
<img src="https://img.shields.io/badge/github%20actions-%232671E5.svg?style=flat&logo=githubactions&logoColor=white" alt="GitHub Actions">
|
|
22
23
|
</p>
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## Requirements
|
|
25
|
+
## Features
|
|
27
26
|
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
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
|
|
31
35
|
|
|
32
36
|
## Installation
|
|
33
37
|
|
|
34
|
-
Install the package using `yarn`, `npm`, or `pnpm`:
|
|
35
|
-
|
|
36
38
|
```bash
|
|
37
|
-
# yarn
|
|
38
|
-
yarn add nestjs-firebase-admin
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# npm
|
|
43
39
|
npm i nestjs-firebase-admin --save
|
|
44
40
|
```
|
|
45
41
|
|
|
42
|
+
<details>
|
|
43
|
+
<summary>yarn / pnpm</summary>
|
|
44
|
+
|
|
46
45
|
```bash
|
|
47
|
-
|
|
48
|
-
pnpm add nestjs-firebase-admin --save
|
|
46
|
+
yarn add nestjs-firebase-admin
|
|
49
47
|
```
|
|
50
48
|
|
|
51
|
-
## Testing
|
|
52
|
-
|
|
53
|
-
To run tests, use the following commands:
|
|
54
|
-
|
|
55
|
-
### Unit Tests
|
|
56
|
-
|
|
57
49
|
```bash
|
|
58
|
-
|
|
50
|
+
pnpm add nestjs-firebase-admin
|
|
59
51
|
```
|
|
60
52
|
|
|
61
|
-
|
|
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
|
+
```
|
|
62
77
|
|
|
63
|
-
|
|
64
|
-
|
|
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 {}
|
|
65
103
|
```
|
|
66
104
|
|
|
67
|
-
|
|
105
|
+
## Usage examples
|
|
68
106
|
|
|
69
|
-
|
|
70
|
-
npm run test:watch
|
|
71
|
-
```
|
|
107
|
+
Once `AdminModule` is imported, inject any service:
|
|
72
108
|
|
|
73
|
-
|
|
109
|
+
```ts
|
|
110
|
+
import { Injectable } from '@nestjs/common';
|
|
111
|
+
import { AuthService, FirestoreService } from 'nestjs-firebase-admin';
|
|
74
112
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
113
|
+
@Injectable()
|
|
114
|
+
export class UsersService {
|
|
115
|
+
constructor(
|
|
116
|
+
private readonly auth: AuthService,
|
|
117
|
+
private readonly firestore: FirestoreService,
|
|
118
|
+
) {}
|
|
78
119
|
|
|
79
|
-
|
|
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
|
+
}
|
|
80
125
|
|
|
81
|
-
|
|
126
|
+
async getUser(uid: string) {
|
|
127
|
+
return this.firestore.get(`users/${uid}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
82
131
|
|
|
83
|
-
|
|
84
|
-
- **Lint**: `npm run lint`
|
|
85
|
-
- **Format**: `npm run format`
|
|
86
|
-
- **Release**: `npm run release`
|
|
132
|
+
## Requirements
|
|
87
133
|
|
|
88
|
-
|
|
134
|
+
| Dependency | Version |
|
|
135
|
+
|-----------|---------|
|
|
136
|
+
| Node.js | >= 20 |
|
|
137
|
+
| NestJS | >= 7.0.0 |
|
|
138
|
+
| firebase-admin | >= 13.0.0 |
|
|
89
139
|
|
|
90
|
-
|
|
140
|
+
## Documentation
|
|
91
141
|
|
|
92
|
-
|
|
142
|
+
Full documentation is available at **[hebertcisco.github.io/nestjs-firebase-admin](https://hebertcisco.github.io/nestjs-firebase-admin/)**.
|
|
93
143
|
|
|
94
|
-
|
|
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)
|
|
95
151
|
|
|
96
|
-
|
|
152
|
+
## Contributing
|
|
97
153
|
|
|
98
|
-
|
|
99
|
-
<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" />
|
|
100
|
-
</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).
|
|
101
155
|
|
|
102
|
-
##
|
|
156
|
+
## License
|
|
103
157
|
|
|
104
|
-
|
|
158
|
+
[MIT](LICENSE)
|
package/_coverpage.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+

|
|
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)
|
|
@@ -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.
|
|
42
|
+
const response = yield this.messaging.sendEachForMulticast(message);
|
|
43
43
|
return response;
|
|
44
44
|
});
|
|
45
45
|
}
|
package/docs/getting-started.md
CHANGED
|
@@ -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
|
-
|
|
64
|
+
inject: [ConfigService],
|
|
65
|
+
useFactory: async (config: ConfigService) => ({
|
|
64
66
|
credential: {
|
|
65
|
-
projectId: '
|
|
66
|
-
clientEmail: '
|
|
67
|
-
privateKey: '
|
|
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:
|
|
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
|
|
9
|
-
- Topic messaging
|
|
10
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
| `
|
|
74
|
-
| `
|
|
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/docs/testing.md
CHANGED
|
@@ -64,4 +64,4 @@ Mock implementations are provided for Firebase services to ensure tests do not m
|
|
|
64
64
|
|
|
65
65
|
## Continuous Integration
|
|
66
66
|
|
|
67
|
-
Tests are automatically run in CI pipelines using GitHub Actions
|
|
67
|
+
Tests are automatically run in CI pipelines using GitHub Actions. Refer to the respective configuration files for more details.
|
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
|
-
|
|
10
|
-
|
|
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
|
|
14
|
-
<meta name="keywords"
|
|
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
|
-
|
|
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="
|
|
56
|
-
<script src="
|
|
57
|
-
<script src="
|
|
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.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Firebase Admin SDK for Nestjs",
|
|
5
|
-
"author": "
|
|
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": {
|
|
@@ -31,10 +46,10 @@
|
|
|
31
46
|
"postversion": "git push && git push --tags"
|
|
32
47
|
},
|
|
33
48
|
"dependencies": {
|
|
34
|
-
"@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1",
|
|
35
|
-
"@nestjs/core": "
|
|
36
|
-
"@nestjs/platform-express": "^
|
|
37
|
-
"firebase-admin": "
|
|
49
|
+
"@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1 || ^11.0.0",
|
|
50
|
+
"@nestjs/core": "^11.1.18",
|
|
51
|
+
"@nestjs/platform-express": "^11.1.18",
|
|
52
|
+
"firebase-admin": "^13.0.0",
|
|
38
53
|
"nest-shared": "^5.0.6"
|
|
39
54
|
},
|
|
40
55
|
"engines": {
|
|
@@ -44,20 +59,20 @@
|
|
|
44
59
|
"devDependencies": {
|
|
45
60
|
"@commitlint/cli": "18.6.1",
|
|
46
61
|
"@commitlint/config-angular": "18.6.1",
|
|
47
|
-
"@nestjs/testing": "
|
|
62
|
+
"@nestjs/testing": "^11.1.18",
|
|
48
63
|
"@types/jest": "29.5.14",
|
|
49
64
|
"@types/node": "20.17.9",
|
|
50
65
|
"@types/supertest": "^2.0.16",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
52
|
-
"@typescript-eslint/parser": "^
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
67
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
53
68
|
"eslint": "8.57.1",
|
|
54
69
|
"eslint-config-prettier": "9.1.0",
|
|
55
70
|
"eslint-plugin-import": "2.31.0",
|
|
56
|
-
"eslint-plugin-jest": "^
|
|
71
|
+
"eslint-plugin-jest": "^28.8.0",
|
|
57
72
|
"eslint-plugin-prettier": "^5.2.1",
|
|
58
73
|
"husky": "8.0.3",
|
|
59
74
|
"jest": "29.7.0",
|
|
60
|
-
"lint-staged": "15.2
|
|
75
|
+
"lint-staged": "^15.5.2",
|
|
61
76
|
"prettier": "^3.4.2",
|
|
62
77
|
"reflect-metadata": "0.2.2",
|
|
63
78
|
"release-it": "^19.0.2",
|
|
@@ -68,7 +83,7 @@
|
|
|
68
83
|
"typescript": "5.7.2"
|
|
69
84
|
},
|
|
70
85
|
"peerDependencies": {
|
|
71
|
-
"@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1",
|
|
86
|
+
"@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.2.1 || ^10.2.1 || ^11.0.0",
|
|
72
87
|
"reflect-metadata": "^0.2.2",
|
|
73
88
|
"rxjs": "^6.0.0 || ^7.0.0"
|
|
74
89
|
},
|
package/robots.txt
ADDED
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>
|