@angular/fire 16.0.0-canary.e04cd7f → 16.0.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/README.md +200 -0
- package/analytics/analytics.module.d.ts +2 -2
- package/analytics/firebase.d.ts +4 -1
- package/analytics/screen-tracking.service.d.ts +3 -3
- package/app-check/app-check.d.ts +0 -6
- package/app-check/app-check.module.d.ts +3 -4
- package/app-check/firebase.d.ts +2 -1
- package/app-check/public_api.d.ts +2 -1
- package/auth/auth.module.d.ts +2 -2
- package/auth/firebase.d.ts +3 -1
- package/auth-guard/auth-guard.d.ts +2 -2
- package/compat/analytics/analytics.d.ts +1 -3
- package/compat/analytics/analytics.module.d.ts +1 -1
- package/compat/analytics/screen-tracking.service.d.ts +1 -1
- package/compat/analytics/user-tracking.service.d.ts +1 -1
- package/compat/auth/auth.d.ts +3 -3
- package/compat/auth-guard/auth-guard.d.ts +2 -2
- package/compat/database/database.d.ts +4 -4
- package/compat/database/interfaces.d.ts +2 -2
- package/compat/database/list/audit-trail.d.ts +1 -1
- package/compat/database/list/create-reference.d.ts +1 -1
- package/compat/database/list/data-operation.d.ts +1 -1
- package/compat/database/list/state-changes.d.ts +1 -1
- package/compat/database/object/create-reference.d.ts +1 -1
- package/compat/database/observable/fromRef.d.ts +1 -1
- package/compat/database/utils.d.ts +1 -1
- package/compat/firebase.app.module.d.ts +1 -1
- package/compat/firestore/collection/collection.d.ts +2 -2
- package/compat/firestore/collection-group/collection-group.d.ts +2 -2
- package/compat/firestore/document/document.d.ts +4 -4
- package/compat/firestore/firestore.d.ts +7 -7
- package/compat/firestore/interfaces.d.ts +2 -2
- package/compat/functions/functions.d.ts +3 -3
- package/compat/messaging/messaging.d.ts +2 -2
- package/compat/performance/performance.d.ts +2 -2
- package/compat/remote-config/remote-config.d.ts +15 -49
- package/compat/storage/observable/fromTask.d.ts +1 -2
- package/compat/storage/ref.d.ts +1 -1
- package/compat/storage/storage.d.ts +3 -3
- package/compat/storage/task.d.ts +1 -1
- package/core.d.ts +7 -0
- package/database/database.module.d.ts +2 -2
- package/docs/analytics.md +67 -0
- package/docs/app-check.md +53 -0
- package/docs/auth.md +165 -0
- package/docs/compat/analytics/getting-started.md +137 -0
- package/docs/compat/auth/getting-started.md +162 -0
- package/docs/compat/auth/router-guards.md +104 -0
- package/docs/compat/emulators/emulators.md +134 -0
- package/docs/compat/firestore/collections.md +326 -0
- package/docs/compat/firestore/documents.md +115 -0
- package/docs/compat/firestore/offline-data.md +39 -0
- package/docs/compat/firestore/querying-collections.md +204 -0
- package/docs/compat/functions/functions.md +166 -0
- package/docs/compat/messaging/messaging.md +232 -0
- package/docs/compat/performance/getting-started.md +132 -0
- package/docs/compat/remote-config/getting-started.md +134 -0
- package/docs/compat/rtdb/lists.md +257 -0
- package/docs/compat/rtdb/objects.md +182 -0
- package/docs/compat/rtdb/querying-lists.md +155 -0
- package/docs/compat/storage/storage.md +257 -0
- package/docs/compat.md +70 -0
- package/docs/database.md +175 -0
- package/docs/deploy/getting-started.md +204 -0
- package/docs/firebase.json +16 -0
- package/docs/firestore.md +148 -0
- package/docs/functions.md +52 -0
- package/docs/images/analytics-illo_1x.png +0 -0
- package/docs/images/auth-illo_1x.png +0 -0
- package/docs/images/cloud-messaging-illo_1x.png +0 -0
- package/docs/images/database-illo_1x.png +0 -0
- package/docs/images/firestore-illo_1x.png +0 -0
- package/docs/images/functions-illo_1x.png +0 -0
- package/docs/images/hosting-illo_1x.png +0 -0
- package/docs/images/performance-illo_1x.png +0 -0
- package/docs/images/reCAPTCHA-logo@1x.png +0 -0
- package/docs/images/remote-config-illo_1x.png +0 -0
- package/docs/images/storage-illo_1x.png +0 -0
- package/docs/install-and-setup.md +114 -0
- package/docs/install-angular-cli-windows10.md +82 -0
- package/docs/install-firebase-tools.md +78 -0
- package/docs/messaging.md +25 -0
- package/docs/performance.md +57 -0
- package/docs/remote-config.md +53 -0
- package/docs/storage.md +90 -0
- package/docs/universal/cloud-functions.md +96 -0
- package/docs/universal/getting-started.md +28 -0
- package/docs/universal/prerendering.md +72 -0
- package/docs/version-4-upgrade.md +119 -0
- package/docs/version-5-upgrade.md +82 -0
- package/docs/version-6-upgrade.md +16 -0
- package/docs/version-7-upgrade.md +298 -0
- package/esm2022/analytics/analytics.mjs +1 -1
- package/esm2022/analytics/analytics.module.mjs +10 -10
- package/esm2022/analytics/firebase.mjs +5 -2
- package/esm2022/analytics/screen-tracking.service.mjs +11 -10
- package/esm2022/analytics/user-tracking.service.mjs +5 -5
- package/esm2022/app/app.mjs +1 -1
- package/esm2022/app/app.module.mjs +9 -8
- package/esm2022/app-check/app-check.mjs +3 -9
- package/esm2022/app-check/app-check.module.mjs +12 -14
- package/esm2022/app-check/firebase.mjs +3 -2
- package/esm2022/app-check/public_api.mjs +3 -2
- package/esm2022/auth/auth.mjs +1 -1
- package/esm2022/auth/auth.module.mjs +11 -11
- package/esm2022/auth/firebase.mjs +4 -2
- package/esm2022/auth-guard/auth-guard.mjs +8 -6
- package/esm2022/auth-guard/auth-guard.module.mjs +7 -7
- package/esm2022/compat/analytics/analytics.mjs +12 -13
- package/esm2022/compat/analytics/analytics.module.mjs +14 -11
- package/esm2022/compat/analytics/screen-tracking.service.mjs +9 -9
- package/esm2022/compat/analytics/user-tracking.service.mjs +7 -7
- package/esm2022/compat/auth/auth.mjs +13 -13
- package/esm2022/compat/auth/auth.module.mjs +7 -7
- package/esm2022/compat/auth-guard/auth-guard.mjs +8 -6
- package/esm2022/compat/auth-guard/auth-guard.module.mjs +7 -7
- package/esm2022/compat/cache.mjs +2 -1
- package/esm2022/compat/database/database.mjs +10 -10
- package/esm2022/compat/database/database.module.mjs +7 -7
- package/esm2022/compat/database/interfaces.mjs +1 -1
- package/esm2022/compat/database/list/audit-trail.mjs +3 -3
- package/esm2022/compat/database/list/changes.mjs +5 -5
- package/esm2022/compat/database/list/create-reference.mjs +5 -5
- package/esm2022/compat/database/list/data-operation.mjs +1 -1
- package/esm2022/compat/database/list/snapshot-changes.mjs +1 -1
- package/esm2022/compat/database/list/state-changes.mjs +2 -2
- package/esm2022/compat/database/object/create-reference.mjs +2 -2
- package/esm2022/compat/database/object/snapshot-changes.mjs +1 -1
- package/esm2022/compat/database/observable/fromRef.mjs +3 -2
- package/esm2022/compat/database/utils.mjs +1 -1
- package/esm2022/compat/firebase.app.mjs +1 -1
- package/esm2022/compat/firebase.app.module.mjs +11 -9
- package/esm2022/compat/firestore/collection/changes.mjs +2 -2
- package/esm2022/compat/firestore/collection/collection.mjs +4 -4
- package/esm2022/compat/firestore/collection-group/collection-group.mjs +4 -4
- package/esm2022/compat/firestore/document/document.mjs +4 -4
- package/esm2022/compat/firestore/firestore.mjs +11 -11
- package/esm2022/compat/firestore/firestore.module.mjs +7 -7
- package/esm2022/compat/firestore/interfaces.mjs +1 -1
- package/esm2022/compat/firestore/observable/fromRef.mjs +2 -2
- package/esm2022/compat/functions/functions.mjs +8 -8
- package/esm2022/compat/functions/functions.module.mjs +7 -7
- package/esm2022/compat/messaging/messaging.mjs +13 -12
- package/esm2022/compat/messaging/messaging.module.mjs +7 -7
- package/esm2022/compat/performance/performance.mjs +14 -20
- package/esm2022/compat/performance/performance.module.mjs +8 -9
- package/esm2022/compat/performance/performance.service.mjs +5 -4
- package/esm2022/compat/proxy.mjs +6 -7
- package/esm2022/compat/remote-config/remote-config.mjs +10 -11
- package/esm2022/compat/remote-config/remote-config.module.mjs +7 -7
- package/esm2022/compat/storage/observable/fromTask.mjs +3 -1
- package/esm2022/compat/storage/pipes/storageUrl.pipe.mjs +9 -9
- package/esm2022/compat/storage/ref.mjs +3 -3
- package/esm2022/compat/storage/storage.mjs +8 -8
- package/esm2022/compat/storage/storage.module.mjs +7 -7
- package/esm2022/compat/storage/task.mjs +2 -2
- package/esm2022/core.mjs +7 -1
- package/esm2022/database/database.mjs +1 -1
- package/esm2022/database/database.module.mjs +11 -11
- package/esm2022/firestore/firebase.mjs +22 -2
- package/esm2022/firestore/firestore.mjs +1 -1
- package/esm2022/firestore/firestore.module.mjs +11 -11
- package/esm2022/firestore/lite/firebase.mjs +11 -2
- package/esm2022/firestore/lite/lite.mjs +1 -1
- package/esm2022/firestore/lite/lite.module.mjs +10 -11
- package/esm2022/firestore/lite/rxfire.mjs +4 -2
- package/esm2022/firestore/rxfire.mjs +4 -4
- package/esm2022/functions/functions.mjs +1 -1
- package/esm2022/functions/functions.module.mjs +11 -11
- package/esm2022/messaging/messaging.mjs +1 -1
- package/esm2022/messaging/messaging.module.mjs +9 -9
- package/esm2022/performance/performance.mjs +1 -1
- package/esm2022/performance/performance.module.mjs +12 -12
- package/esm2022/remote-config/is-remote-config-supported-factory.mjs +2 -2
- package/esm2022/remote-config/remote-config.mjs +1 -1
- package/esm2022/remote-config/remote-config.module.mjs +9 -9
- package/esm2022/storage/storage.mjs +1 -1
- package/esm2022/storage/storage.module.mjs +11 -11
- package/esm2022/zones.mjs +9 -11
- package/fesm2022/angular-fire-analytics.mjs +18 -14
- package/fesm2022/angular-fire-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-app-check.mjs +13 -19
- package/fesm2022/angular-fire-app-check.mjs.map +1 -1
- package/fesm2022/angular-fire-app.mjs +6 -5
- package/fesm2022/angular-fire-app.mjs.map +1 -1
- package/fesm2022/angular-fire-auth-guard.mjs +13 -11
- package/fesm2022/angular-fire-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-auth.mjs +10 -9
- package/fesm2022/angular-fire-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-analytics.mjs +29 -27
- package/fesm2022/angular-fire-compat-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth-guard.mjs +12 -10
- package/fesm2022/angular-fire-compat-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth.mjs +13 -13
- package/fesm2022/angular-fire-compat-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-database.mjs +129 -128
- package/fesm2022/angular-fire-compat-database.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-firestore.mjs +96 -96
- package/fesm2022/angular-fire-compat-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-functions.mjs +10 -10
- package/fesm2022/angular-fire-compat-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-messaging.mjs +13 -12
- package/fesm2022/angular-fire-compat-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-performance.mjs +23 -29
- package/fesm2022/angular-fire-compat-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-remote-config.mjs +10 -11
- package/fesm2022/angular-fire-compat-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-storage.mjs +21 -19
- package/fesm2022/angular-fire-compat-storage.mjs.map +1 -1
- package/fesm2022/angular-fire-compat.mjs +15 -13
- package/fesm2022/angular-fire-compat.mjs.map +1 -1
- package/fesm2022/angular-fire-database.mjs +7 -8
- package/fesm2022/angular-fire-database.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore-lite.mjs +21 -11
- package/fesm2022/angular-fire-firestore-lite.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore.mjs +32 -13
- package/fesm2022/angular-fire-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-functions.mjs +8 -9
- package/fesm2022/angular-fire-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-messaging.mjs +4 -4
- package/fesm2022/angular-fire-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-performance.mjs +7 -7
- package/fesm2022/angular-fire-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-remote-config.mjs +4 -4
- package/fesm2022/angular-fire-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-storage.mjs +6 -7
- package/fesm2022/angular-fire-storage.mjs.map +1 -1
- package/fesm2022/angular-fire.mjs +14 -10
- package/fesm2022/angular-fire.mjs.map +1 -1
- package/firestore/firebase.d.ts +21 -1
- package/firestore/firestore.module.d.ts +2 -2
- package/firestore/lite/firebase.d.ts +10 -1
- package/firestore/lite/lite.module.d.ts +2 -2
- package/firestore/lite/rxfire.d.ts +3 -1
- package/firestore/rxfire.d.ts +3 -3
- package/functions/functions.module.d.ts +2 -2
- package/messaging/messaging.module.d.ts +2 -2
- package/package.json +18 -18
- package/performance/performance.module.d.ts +2 -2
- package/remote-config/remote-config.module.d.ts +2 -2
- package/schematics/add/index.js +1 -1
- package/schematics/add/schema.json +16 -0
- package/schematics/builders.json +10 -0
- package/schematics/collection.json +15 -0
- package/schematics/common.js +1 -1
- package/schematics/deploy/actions.js +11 -11
- package/schematics/deploy/builder.js +2 -2
- package/schematics/deploy/schema.json +119 -0
- package/schematics/interfaces.js +9 -8
- package/schematics/migration.json +15 -0
- package/schematics/setup/index.js +33 -50
- package/schematics/setup/prompts.js +5 -6
- package/schematics/setup/schema.json +16 -0
- package/schematics/update/index.js +1 -1
- package/schematics/update/v7/index.js +2 -2
- package/schematics/utils.js +79 -63
- package/storage/storage.module.d.ts +2 -2
- package/publish.sh +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Deploy your application on Firebase Hosting & Functions
|
|
2
|
+
|
|
3
|
+
In this guide, we'll look at how to use `@angular/fire` to automatically deploy an Angular application to Firebase hosting or functions by using the Angular CLI.
|
|
4
|
+
|
|
5
|
+
`@angular/fire` uses Firebase functions to deploy your Angular universal projects, with server-side rendering enabled.
|
|
6
|
+
|
|
7
|
+
**Angular Universal deployments work with `@nguniversal/*` version 9.0.0 and above**.
|
|
8
|
+
|
|
9
|
+
## Step 1: add `@angular/fire` to your project
|
|
10
|
+
|
|
11
|
+
First, you need to add the `@angular/fire` package to your project. In your Angular CLI project run:
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
ng add @angular/fire
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
*Note that the command above assumes you have global Angular CLI installed. To install Angular CLI globally run `npm i -g @angular/cli`.*
|
|
18
|
+
|
|
19
|
+
First, the command above will check if you have an Angular universal project. It'll do so by looking at your `angular.json` project, looking for a `server` target for the specified project. If it finds one, it'll ask you if you want to deploy the project in a firebase function.
|
|
20
|
+
|
|
21
|
+
After that it will trigger the `@angular/fire` `ng-add` schematics. The schematics will open a web browser and guide you through the Firebase authentication flow (if you're not signed in already). After you authenticate, you'll see a prompt to select a Firebase hosting project.
|
|
22
|
+
|
|
23
|
+
The schematics will do the following:
|
|
24
|
+
|
|
25
|
+
- Add `@angular/fire` to your list of dependencies
|
|
26
|
+
- Create `firebase.json`, `.firebaserc` files in the root of your workspace. You can use them to configure your firebase hosting deployment. Find more about them [here](https://firebase.google.com/docs/hosting/full-config)
|
|
27
|
+
- Update your workspace file (`angular.json`) by inserting the `deploy` builder
|
|
28
|
+
|
|
29
|
+
In the end, your `angular.json` project will look like below:
|
|
30
|
+
|
|
31
|
+
```json5
|
|
32
|
+
{
|
|
33
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
34
|
+
"version": 1,
|
|
35
|
+
"newProjectRoot": "projects",
|
|
36
|
+
"projects": {
|
|
37
|
+
"sample-app": {
|
|
38
|
+
// ...
|
|
39
|
+
"deploy": {
|
|
40
|
+
"builder": "@angular/fire:deploy",
|
|
41
|
+
"options": {} // Here you may find an "ssr": true option if you've
|
|
42
|
+
// selected that you want to deploy your Angular universal project
|
|
43
|
+
// as a firebase function.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
// ...
|
|
48
|
+
"defaultProject": "sample-app"
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If you want to add deployment capabilities to a different project in your workspace, you can run:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
ng add @angular/fire --project=[PROJECT_NAME]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Step 2: deploying the project
|
|
60
|
+
|
|
61
|
+
As the second step, to deploy your project run:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
ng deploy --project=[PROJECT_NAME]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
*The `--project` option is optional. Learn more [here](https://angular.io/cli/deploy).*
|
|
68
|
+
|
|
69
|
+
The command above will trigger:
|
|
70
|
+
|
|
71
|
+
1. Production build of your application
|
|
72
|
+
2. Deployment of the produced assets to the firebase hosting project you selected during `ng add`
|
|
73
|
+
|
|
74
|
+
If you've specified that you want a server-side rendering enabled deployment in a firebase function, the command will also:
|
|
75
|
+
|
|
76
|
+
1. Create a firebase function in `dist`, which directly consumes `main.js` from your server output directory.
|
|
77
|
+
2. Create `package.json` for the firebase function with the required dependencies.
|
|
78
|
+
3. Deploy the static assets to firebase hosting and your universal server as a Firebase function.
|
|
79
|
+
|
|
80
|
+
If you want to preview your Angular Universal project before we deploy it as a Firebase Function you can run:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
ng deploy --preview
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
We'll create the function and a `package.json` in your project output directory. This way, you can later run `firebase serve` in your project root so you can test everything before deploying.
|
|
87
|
+
|
|
88
|
+
## Step 3: customization
|
|
89
|
+
|
|
90
|
+
To customize the deployment flow, you can use the configuration files you're already familiar with from `firebase-tools`. You can find more in the [firebase documentation](https://firebase.google.com/docs/hosting/full-config).
|
|
91
|
+
|
|
92
|
+
### Configuring Cloud Functions
|
|
93
|
+
|
|
94
|
+
Setting `functionsNodeVersion` and `functionsRuntimeOptions` in your `angular.json` allow you to customize the version of Node.js Cloud Functions is running and run-time settings like timeout, VPC connectors, and memory.
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
"deploy": {
|
|
98
|
+
"builder": "@angular/fire:deploy",
|
|
99
|
+
"options": {
|
|
100
|
+
"functionsNodeVersion": 12,
|
|
101
|
+
"functionsRuntimeOptions": {
|
|
102
|
+
"memory": "2GB",
|
|
103
|
+
"timeoutSeconds": 10,
|
|
104
|
+
"vpcConnector": "my-vpc-connector",
|
|
105
|
+
"vpcConnectorEgressSettings": "PRIVATE_RANGES_ONLY"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Working with multiple Firebase Projects
|
|
112
|
+
|
|
113
|
+
If you have multiple build targets and deploy targets, it is possible to specify them in your `angular.json` or `workspace.json`.
|
|
114
|
+
|
|
115
|
+
It is possible to use either your project name or project alias in `firebaseProject`. The setting provided here is equivalent to passing a project name or alias to `firebase deploy --project projectNameOrAlias`.
|
|
116
|
+
|
|
117
|
+
The `buildTarget` simply points to an existing build configuration for your project. Most projects have a default configuration and a production configuration (commonly activated by using the `--prod` flag) but it is possible to specify as many build configurations as needed.
|
|
118
|
+
|
|
119
|
+
You may specify a `buildTarget` and `firebaseProject` in your `options` as follows:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
"deploy": {
|
|
123
|
+
"builder": "@angular/fire:deploy",
|
|
124
|
+
"options": {
|
|
125
|
+
"buildTarget": "projectName:build",
|
|
126
|
+
"firebaseProject": "developmentProject"
|
|
127
|
+
},
|
|
128
|
+
"configurations": {
|
|
129
|
+
"production": {
|
|
130
|
+
"buildTarget": "projectName:build:production",
|
|
131
|
+
"firebaseProject": "productionProject"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The above configuration specifies the following:
|
|
138
|
+
|
|
139
|
+
1. `ng deploy` will deploy the default project with default configuration.
|
|
140
|
+
2. `ng deploy projectName` will deploy the specified project with default configuration.
|
|
141
|
+
3. `ng deploy projectName --prod` or `ng deploy projectName --configuration='production'` will deploy `projectName` with production build settings to your production environment.
|
|
142
|
+
|
|
143
|
+
All of the options are optional. If you do not specify a `buildTarget`, it defaults to a production build (`projectName:build:production`). If you do not specify a `firebaseProject`, it defaults to the first matching deploy target found in your `.firebaserc` (where your projectName is the same as your Firebase deploy target name). The `configurations` section is also optional.
|
|
144
|
+
|
|
145
|
+
### Working with multiple project sites
|
|
146
|
+
|
|
147
|
+
For example, if you have muti sites config in firebase.json like this:
|
|
148
|
+
```
|
|
149
|
+
{
|
|
150
|
+
"hosting": [
|
|
151
|
+
{
|
|
152
|
+
"target": "custom-site",
|
|
153
|
+
"public": "public/my-custom-site",
|
|
154
|
+
"ignore": [
|
|
155
|
+
"firebase.json",
|
|
156
|
+
"**/.*",
|
|
157
|
+
"**/node_modules/**"
|
|
158
|
+
],
|
|
159
|
+
"rewrites": [
|
|
160
|
+
{
|
|
161
|
+
"source": "**",
|
|
162
|
+
"destination": "/index.html"
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
If you have multiple build targets and deploy targets, it is possible to specify them in your `angular.json` or `workspace.json`.
|
|
170
|
+
|
|
171
|
+
It is possible to use either your project name or project alias in `siteTarget`.
|
|
172
|
+
|
|
173
|
+
You may specify a `siteTarget` in your `options` as follows:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
"deploy": {
|
|
177
|
+
"builder": "@angular/fire:deploy",
|
|
178
|
+
"options": {
|
|
179
|
+
"buildTarget": "projectName:build",
|
|
180
|
+
"firebaseProject": "developmentProject",
|
|
181
|
+
"siteTarget": "yourDefaultSiteTarget"
|
|
182
|
+
},
|
|
183
|
+
"configurations": {
|
|
184
|
+
"production": {
|
|
185
|
+
"buildTarget": "projectName:build:production",
|
|
186
|
+
"firebaseProject": "productionProject",
|
|
187
|
+
"siteTarget": "yourProdSiteTarget"
|
|
188
|
+
},
|
|
189
|
+
"storybook": {
|
|
190
|
+
"buildTarget": "projectName:build-storybook",
|
|
191
|
+
"firebaseProject": "developmentProject",
|
|
192
|
+
"siteTarget": "yourStorybookSiteTarget"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
The above configuration specifies the following:
|
|
199
|
+
|
|
200
|
+
1. `ng deploy` will deploy the default project with default configuration.
|
|
201
|
+
2. `ng deploy projectName` will deploy the specified project with default configuration.
|
|
202
|
+
3. `ng deploy projectName --configuration=storybook --siteTarget=mySiteTarget` will deploy `projectName` to `mySiteTarget` with configuration`storybook`.
|
|
203
|
+
|
|
204
|
+
All of the options are optional
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/firestore-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Cloud Firestore
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Cloud Firestore
|
|
8
|
+
|
|
9
|
+
Cloud Firestore is a flexible, scalable NoSQL database for mobile, web, and server development from Firebase and Google Cloud. It keeps your data in sync across client apps through realtime listeners and offers offline support for mobile and web so you can build responsive apps that work regardless of network latency or Internet connectivity.
|
|
10
|
+
|
|
11
|
+
[Learn more](https://firebase.google.com/docs/firestore)
|
|
12
|
+
|
|
13
|
+
Cloud Firestore is the API that gives your application access to your database in the cloud or locally in your [emulator](https://firebase.google.com/docs/emulator-suite).
|
|
14
|
+
|
|
15
|
+
## Dependency Injection
|
|
16
|
+
|
|
17
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
18
|
+
```bash
|
|
19
|
+
ng add @angular/fire
|
|
20
|
+
```
|
|
21
|
+
Provide a Firestore instance in the application's `NgModule` (`app.module.ts`):
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
@NgModule({
|
|
25
|
+
declarations: [
|
|
26
|
+
...
|
|
27
|
+
],
|
|
28
|
+
imports: [
|
|
29
|
+
...
|
|
30
|
+
// App initialization
|
|
31
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
32
|
+
provideFirestore(() => getFirestore())
|
|
33
|
+
],
|
|
34
|
+
providers: [],
|
|
35
|
+
bootstrap: [AppComponent]
|
|
36
|
+
})
|
|
37
|
+
export class AppModule { }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
In your component class, for example `user-profile.component.ts` import and inject `Firestore`:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Component, inject } from '@angular/core';
|
|
45
|
+
import { Firestore } from '@angular/fire/firestore';
|
|
46
|
+
|
|
47
|
+
@Component({
|
|
48
|
+
standalone: true,
|
|
49
|
+
selector: 'app-user-profile',
|
|
50
|
+
...
|
|
51
|
+
})
|
|
52
|
+
export class UserProfileComponent {
|
|
53
|
+
private firestore: Firestore = inject(Firestore);
|
|
54
|
+
...
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Firebase API
|
|
59
|
+
With the reference to Cloud Firestore available in a component it is now possible to connect read from and write to the database.
|
|
60
|
+
|
|
61
|
+
### Reading data
|
|
62
|
+
In Cloud Firestore data is stored in `documents` and `documents` are stored in `collections`. The path to data follows `<collection_name>/<document_id>` and continues if there are subcollections. For example, `"users/ABC12345/posts/XYZ6789"` represents:
|
|
63
|
+
* `users` collection
|
|
64
|
+
* document id `ABC12345`
|
|
65
|
+
* `posts` collection
|
|
66
|
+
* document id `XYZ6789`
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Let's explore reading data in Angular using the `collection` and `collectionData` functions.
|
|
70
|
+
|
|
71
|
+
In `user-profile.component.ts`:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { Firestore, collection, collectionData} from '@angular/fire/firestore';
|
|
75
|
+
import { Component, inject } from '@angular/core';
|
|
76
|
+
|
|
77
|
+
@Component ({
|
|
78
|
+
selector: 'app-user-profile',
|
|
79
|
+
standalone: true,
|
|
80
|
+
...
|
|
81
|
+
})
|
|
82
|
+
export class UserProfileComponent {
|
|
83
|
+
private firestore: Firestore = inject(Firestore); // inject Cloud Firestore
|
|
84
|
+
users$: Observable<UserProfile[]>;
|
|
85
|
+
|
|
86
|
+
constructor() {
|
|
87
|
+
// get a reference to the user-profile collection
|
|
88
|
+
const userProfileCollection = collection(this.firestore, 'users');
|
|
89
|
+
|
|
90
|
+
// get documents (data) from the collection using collectionData
|
|
91
|
+
this.users$ = collectionData(userProfileCollection) as Observable<UserProfile[]>;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export Interface UserProfile {
|
|
95
|
+
username: string;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
`collectionData` returns an `observable` that can we can use to display the data in the template. In `user-profile.component.html`:
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<section>
|
|
102
|
+
<h1>User Profiles</h1>
|
|
103
|
+
<ul>
|
|
104
|
+
<li *ngFor="let user of users$ | async">
|
|
105
|
+
{{user.username}}
|
|
106
|
+
</li>
|
|
107
|
+
</ul>
|
|
108
|
+
</section>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The `async` pipe handles unsubscribing from observables.
|
|
112
|
+
|
|
113
|
+
### Writing data
|
|
114
|
+
To write to Cloud Firestore use the `addDoc` function. It will create a new document at the path specified by the collection. In `user-profile.component.ts`, we'll update the code to add a new document on a `<button>` click.
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { Firestore, collection, collectionData, addDoc} from '@angular/fire/firestore';
|
|
119
|
+
import { Component, inject } from '@angular/core';
|
|
120
|
+
|
|
121
|
+
@Component ({
|
|
122
|
+
selector: 'app-user-profile',
|
|
123
|
+
standalone: true,
|
|
124
|
+
...
|
|
125
|
+
})
|
|
126
|
+
export class UserProfileComponent {
|
|
127
|
+
private firestore: Firestore = inject(Firestore); // inject Cloud Firestore
|
|
128
|
+
users$: Observable<UserProfile[]>;
|
|
129
|
+
usersCollection: CollectionReference;
|
|
130
|
+
|
|
131
|
+
constructor() {...}
|
|
132
|
+
|
|
133
|
+
addUserProfile(username: string) {
|
|
134
|
+
if (!username) return;
|
|
135
|
+
|
|
136
|
+
addDoc(this.usersCollection, <UserProfile> { username }).then((documentReference: DocumentReference) => {
|
|
137
|
+
// the documentReference provides access to the newly created document
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export Interface UserProfile {
|
|
142
|
+
username: string;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
In the `addUserProfile` method we use a reference to the `this.usersCollection` and provide `UserProfile` data to the the `addDoc` function. `addDoc` returns a promise that can be used to respond to the successful addition of the data. Errors can also be caught here.
|
|
146
|
+
|
|
147
|
+
## Learn More
|
|
148
|
+
More information on API methods and other functions can be found on the [Firebase Official Docs](https://firebase.google.com/docs/reference/js/firestore_)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/functions-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Cloud Functions
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Cloud Functions
|
|
8
|
+
|
|
9
|
+
The Cloud Functions for Firebase client SDKs let you call functions directly from a Firebase app. To call a function from your app in this way, write and deploy an HTTPS Callable function in Cloud Functions, and then add client logic to call the function from your app.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/functions/get-started)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
16
|
+
```bash
|
|
17
|
+
ng add @angular/fire
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Provide a Cloud Functions instance in the application's `NgModule` (`app.module.ts`):
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
+
import { getFunctions, provideFunctions } from '@angular/fire/functions';
|
|
25
|
+
|
|
26
|
+
@NgModule({
|
|
27
|
+
imports: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
29
|
+
provideFunctions(() => getFunctions()),
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Next inject it into your component:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Component, inject} from '@angular/core';
|
|
38
|
+
import { Functions } from '@angular/fire/functions';
|
|
39
|
+
|
|
40
|
+
@Component({ ... })
|
|
41
|
+
export class AppComponent {
|
|
42
|
+
private functions: Functions = inject(Functions);
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Firebase API
|
|
48
|
+
The [Firebase API for Cloud Functions documentation](https://firebase.google.com/docs/reference/js/functions) is available on the Firebase website.
|
|
49
|
+
|
|
50
|
+
## Convenience observables
|
|
51
|
+
|
|
52
|
+
More details coming soon.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# AngularFire Quickstart
|
|
2
|
+
|
|
3
|
+
### 1. Create a new project
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Using yarn create
|
|
7
|
+
yarn create @angular <project-name>
|
|
8
|
+
cd <project-name>
|
|
9
|
+
```
|
|
10
|
+
or
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Using npm create
|
|
14
|
+
npm create @angular <project-name>
|
|
15
|
+
cd <project-name>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
optionally installing the tooling directly:
|
|
19
|
+
```bash
|
|
20
|
+
# Installing the tooling directly
|
|
21
|
+
npm install -g @angular/cli
|
|
22
|
+
ng new <project-name>
|
|
23
|
+
cd <project-name>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The Angular CLI's `new` command will set up the latest Angular build in a new project structure.
|
|
27
|
+
|
|
28
|
+
### 2. Install AngularFire and Firebase
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
ng add @angular/fire
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Now that you have a new project setup, install AngularFire and Firebase from npm. This will complete the following tasks:
|
|
35
|
+
|
|
36
|
+
1. Add Firebase config to environments variables
|
|
37
|
+
2. Configure `@NgModule` for the `AngularFireModule`
|
|
38
|
+
|
|
39
|
+
### 3. Inject `Firestore`
|
|
40
|
+
|
|
41
|
+
Open `/src/app/app.component.ts`, and make the following changes to :
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { Component, inject } from '@angular/core';
|
|
45
|
+
import { Firestore } from '@angular/fire/firestore';
|
|
46
|
+
|
|
47
|
+
@Component({
|
|
48
|
+
selector: 'app-root',
|
|
49
|
+
templateUrl: 'app.component.html',
|
|
50
|
+
styleUrls: ['app.component.css']
|
|
51
|
+
})
|
|
52
|
+
export class AppComponent {
|
|
53
|
+
firestore: Firestore = inject(Firestore);
|
|
54
|
+
|
|
55
|
+
constructor() {
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 4. Bind a Firestore collection to a list
|
|
62
|
+
|
|
63
|
+
In `/src/app/app.component.ts`:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { Component, inject } from '@angular/core';
|
|
67
|
+
import { Firestore, collection, collectionData } from '@angular/fire/firestore';
|
|
68
|
+
import { Observable } from 'rxjs';
|
|
69
|
+
|
|
70
|
+
@Component({
|
|
71
|
+
selector: 'app-root',
|
|
72
|
+
templateUrl: 'app.component.html',
|
|
73
|
+
styleUrls: ['app.component.css']
|
|
74
|
+
})
|
|
75
|
+
export class AppComponent {
|
|
76
|
+
firestore: Firestore = inject(Firestore)
|
|
77
|
+
items$: Observable<any[]>;
|
|
78
|
+
|
|
79
|
+
constructor() {
|
|
80
|
+
const aCollection = collection(this.firestore, 'items')
|
|
81
|
+
this.items$ = collectionData(aCollection);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Open `/src/app/app.component.html`:
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<ul>
|
|
90
|
+
<li class="text" *ngFor="let item of items$ | async">
|
|
91
|
+
{{item.name}}
|
|
92
|
+
</li>
|
|
93
|
+
</ul>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 5. Run your app locally
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
ng serve
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Your Angular app will compile and serve locally, visit it we should find an empty list.
|
|
103
|
+
|
|
104
|
+
In another tab [start adding data to an `items` collection in Firestore](https://firebase.google.com/docs/firestore/manage-data/add-data). *As we're not authenticating users yet, be sure to start Firestore in **test mode** or allow reading from the `items` collection in Security Rules (`allow read: if true`).*
|
|
105
|
+
|
|
106
|
+
Once you've created a `items` collection and are inserting documents, you should find data streaming into your Angular application and being rendered in your browser.
|
|
107
|
+
|
|
108
|
+
### 6. Deploy your app
|
|
109
|
+
|
|
110
|
+
Finally, we can deploy the application to Firebase hosting:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
ng deploy
|
|
114
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Installing Angular CLI on Windows 10
|
|
2
|
+
|
|
3
|
+
> There had been installation issues of `@angular/cli` on Windows 10 system. Most of the time these errors are related to Python dependencies and node-gyp.
|
|
4
|
+
|
|
5
|
+
Something as below :
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
execSync@1.0.2 install C:\Users\User\AppData\Roaming\npm\node_modules\angu
|
|
9
|
+
lar-cli\node_modules\angular2-template-loader\node_modules\codecov\node_modules\
|
|
10
|
+
execSync
|
|
11
|
+
node install.js
|
|
12
|
+
|
|
13
|
+
[execsync v1.0.2] Attempting to compile native extensions.
|
|
14
|
+
{ [Error: spawn node-gyp ENOENT]
|
|
15
|
+
code: 'ENOENT',
|
|
16
|
+
errno: 'ENOENT',
|
|
17
|
+
syscall: 'spawn node-gyp',
|
|
18
|
+
path: 'node-gyp',
|
|
19
|
+
spawnargs: [ 'rebuild' ] }
|
|
20
|
+
[execSync v1.0.2]
|
|
21
|
+
Native code compile failed!!
|
|
22
|
+
Will try to use win32 extension.
|
|
23
|
+
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie h
|
|
24
|
+
ttps://nodesecurity.io/advisories/130
|
|
25
|
+
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher
|
|
26
|
+
to avoid a RegExp DoS issue
|
|
27
|
+
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher
|
|
28
|
+
to avoid a RegExp DoS issue
|
|
29
|
+
|
|
30
|
+
node-zopfli@2.0.1 install C:\Users\User\AppData\Roaming\npm\node_modules\a
|
|
31
|
+
ngular-cli\node_modules\compression-webpack-plugin\node_modules\node-zopfli
|
|
32
|
+
node-pre-gyp install --fallback-to-build
|
|
33
|
+
.......................
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
To resolve this issue, make sure you've upgraded to the latest version of **NPM** and try installing `@angular/cli` again. This seems to have worked on certain scenarios.
|
|
37
|
+
|
|
38
|
+
If the above doesn't work then the below steps should help. Please ensure all the commands are executed as an **Administrator**.
|
|
39
|
+
|
|
40
|
+
## Steps:
|
|
41
|
+
|
|
42
|
+
### 1) Install `node-gyp` from [here](https://github.com/nodejs/node-gyp) using NPM
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install -g node-gyp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 2) Install Windows build tools from [here](https://github.com/felixrieseberg/windows-build-tools) using NPM
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install --global windows-build-tools
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
*This will also install Python
|
|
55
|
+
|
|
56
|
+
### 3) Install Angular CLI
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install -g @angular/cli
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This should install `@angular/cli` without errors.
|
|
63
|
+
|
|
64
|
+
#### Post this installation, follow the installation [guide](https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md) to install AngularFire and everything should work as expected.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Note:
|
|
68
|
+
|
|
69
|
+
When you start your app using `ng serve` in the console, you might still see the below errors. Despite these errors, the application should work as expected and should be able to talk to Firebase.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
ERROR in [default] C:\angularFire2Test\node_modules\angularfire2\interfaces.d.ts:12:34
|
|
73
|
+
Cannot find namespace 'firebase'.
|
|
74
|
+
|
|
75
|
+
ERROR in [default] C:\angularFire2Test\src\typings.d.ts:6:12
|
|
76
|
+
Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire',
|
|
77
|
+
but here has type 'any'.
|
|
78
|
+
|
|
79
|
+
ERROR in [default] C:\angularFire2Test\src\typings.d.ts:7:12
|
|
80
|
+
Subsequent variable declarations must have the same type. Variable 'module' must be of type 'NodeModule',
|
|
81
|
+
but here has type 'any'.
|
|
82
|
+
```
|