This is part 1 of a two-part series covering a full-stack application example.
In this part we walk through setting up a back-end data API, using Google Cloud Functions and Cloud Firestore.
Make sure you have NodeJS installed before proceeding any further. You can check by typing in node -v
at the terminal or command prompt.
Usage steps:
- Log into Google Firebase console
- Create project
- Database -> Cloud Firestore
- Add a collection called 'quiz'
- Add some documents in that collection
Then:
-
npm install -g firebase-tools
-
mkdir project-folder && cd project-folder
- make sure you're inside the project folder before the next step
-
firebase init
- use the arrow keys to move up and down the list of features; we need
Functions
- select
Functions
with spacebar and press Enter - similarly, select the Firebase project name you created earlier
- for the rest of the init prompts, take defaults, i.e. just press Enter
- at the end should say something like
Firebase initialisation complete
- use the arrow keys to move up and down the list of features; we need
-
open your
functions/index.js
in code editor -
paste in code from the file
functions/index.js
that you'll find in this repo -
firebase deploy
at the terminal or command prompt- at the end should say something like
Deploy complete
- deploy needs to be repeated each time you change this code
- at the end should say something like
Make sure that firebase commands like init and deploy are run in your project folder.
Related links and references
Post your questions on any of these forums, attend our events, learn and share.
Happy Coding!