React app to build burgers with a fixed set of ingredients. This app uses axios for HTTP Requests, react-router for routing, redux for state management, and Firebase as the backend.
S3 hosted example: http://vegan-burger-builder-react.s3-website.ca-central-1.amazonaws.com
Firebase hosted example: https://vegan-burger-builder-react.web.app
$ npm install
-
Setup a new project on firebase
-
Go to the Realtime Database page
-
Click on 'Create Database' button. This will create a MongoDB-like database.
-
Take note of the database endpoint, it will be something like: https://[your-project-name].firebaseio.com/
-
Set the rules to:
{ "rules": { "ingredients": { ".read": true, ".write": true, }, "orders": { ".read": "auth != null", ".write": "auth != null", ".indexOn": ["userId"] } } }
- Go the Authentication page
- Go to the Sign-in method tab
- Enable the Email/Password provider
Firebase endpoint for sign up with email/password:
https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=[API_KEY]
Firebase endpoint for sign in with email password:
https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API_KEY]
Firebase endpoint to get user's data:
https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=[API_KEY]
NOTE: You can get your API Key by going to Settings -> General -> Web API Key
For complete docs, check out: https://firebase.google.com/docs/reference/rest/auth#section-api-usage
Create a .env file in the main project folder with the following variables:
REACT_APP_FIREBASE_DB_ENDPOINT=https://[your-project-name].firebaseio.com/
REACT_APP_FIREBASE_API_KEY=yourapikey
$ npm start
$ npm run test
$ npm run build
$ npm install -g firebase-tools
$ firebase login
$ firebase init
Steps:
- Navigate to the following option:
- Hosting: Configure and deploy Firebase Hosting sites
- Select Use an existing project
- Select the project you set up for this app
- What do you want to use as your public directory?
- enter: build
- Configure as a single-page app?
- enter: y
- Overwrite file build/index.html?
- enter: N
$ firebase deploy
NOTE: you can visit your page with the Hosting URL that is outputted once the deploy was successful