Microservice designed with Firebase Cloud Functions and Firestore
- Authentication
- Email Verification on new sign ups
- Unverified emails should deny read and write access
- Email Notification on new books arrival
- The email should also contain details and a link to view the newly added book
Ensure you have the following installed before running npm install
- Node.js
- NPM
- Firebase Tools
Obtain Application API_KEY from Firebase Configs and create keys.ts
in the root directory of the functions
folder
export const firebaseConfig = {
apiKey: "AXXXXXXXXXXXXXXXXXXXXXXXQ",
authDomain: "<APP_NAME>.firebaseapp.com",
databaseURL: "https://<APP_NAME>.firebaseio.com",
projectId: "<PROJECT_ID>",
storageBucket: "<APP_NAME>.appspot.com",
messagingSenderId: "XXXXXXXXXX",
appId: "XXXXXXXXXXXXXXXXXXXXXXXXX"
}
You'd want to upgrade your Firebase Project from the Free Tier to Blaze. Without the upgrade the application will resolve to a netwowrk outofbound ERROR
- Run
npm run deploy
to Deploy ornpm run serve
to test the Cloud Functions
NB: If the emulator fails to run please ensure you are running
firebase-tools 6.9.3
To send emails when a new book is added to your users
- Create a Twilio SendGrid Account https://sendgrid.com
- Obtain API_KEY from
sendgrid
- Update
keys.ts
in the root directory of thefunctions
folder
......
export const SG_APIKEY = 'SG.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
-
auth
/auth
-
[POST]
/login
- Assigns User-Token forfirebase security rules
-
[POST]
/signup
- Creates a new user -
[GET]
/logout
- Remove User-Token -
user
/user
- [GET]
/profile
- Retrives currently logged-in user's profile - [PUT]
/update
- Update Currently logged in user's profile
- [GET]
-book /book
- [POST]
/add
- Add a new book to Firestore - [GET]
/fetch
- Retrives all books from Firestors - [GET]
/fetch/:id
- Retrive book with theid
ofreq.params.id
- [PUT]
/update/:id
- Update book with theid
ofreq.params.id
- [DELETE]
/remove/:id
- Delete book with theid
ofreq.params.id
- onCreateUser - Trigged when a user signsup and sends email using SendGrid
- onBookArrival Trigged when a new book is created and sends email using SendGrid