Configure and run the app with the Firebase Console:
Follow these steps to have a working version of the quickstart running with the Firebase console:
Note: In the original application (that runs on the emulators), there is a Firebase Function that updates the avgRating
field of a restaurant whenever that restaurant recieves a review. While Authentication, Storage, and Firestore are offered as free services through the Firebase console, using Firebase Functions on the Firebase Console requires a billing plan. There is a free tier billing plan that allows up to 2 million free function calls per month, but enabling this plan requires presenting payment information to Firebase. The following instructions, therefore, exclude those steps needed to deploy and host functions on the Firebase Console. All application functionality, other than the auto-updating avgRating
field for restaurants, is conserved.
Create a new Firebase project in the Firebase Console
On the project homepage, select Web
under Get Started By Adding Firebase To Your App
and follow prompts to create your app, making sure to copy the firebaseConfig
object when presented.
With the firebaseConfig
copied, navigate to src/environments/environments.prod.ts
and paste the contents of the object into the environment
object:
Back in the Firebase console, enable email and password authentication on your project by doing: Authentication > SIGN-IN METHOD > Email > Email/Password > SAVE
In the Firebase console, enable Firestore on your project by clicking Create Database in the Cloud Firestore section of the console and answering all prompts.
- When prompted, select "Start in Test Mode"
Simmilarly, enable Cloud Storage on your project by clicking Get Started in the Storage section of the console and answering all prompts.
- When prompted, select "Start in Test Mode"
Set the CLI to use the project you created in Step 1:
firebase --use add
Serve your Angular app and see it connect to the Firebase Console by opening http://localhost:4200 in your browser!
npm run production
Note: If you've opted to set up a billing plan and wish to deploy functions as well, replace the firebase deploy --only firestore
on line 8 of package.json
with firebase deploy
.
(Optional) Populate production Firestore with mock data
Now that the application is live on the Firebase console, you likely want to add some data to your production Firestore database so that you can see the application in action. Rather than manually adding restaurants and reviews, a convenice script is available to populate your production Firestore database. Run the following command (defined in the Firestore/
directory's package.json
) to add mock data:
npm run populate-production
Note: To ensure that the script runs as intended, make sure that you have correctly populated the environemnt.prod.ts
file with your Firebase credentials.