- Angular app using Firebase tools
- Firebase Functions used with express server to access a realtime database
- Note: to open web links in a new window use: ctrl+click on link
- Firebase project realtime database key-value pair created in Firebase Console
- Project service account created via Firebase Project Settings then
Create Service Account/Node.js (default option)thenGenerate new private keythat adds a json file to the user's PC. The path to this access key file is referenced in the express serverindex.tsfile - This is just a very simple example to demonstrate how a Firebase database function works
- Angular v15
- Firebase v9 Cloud storage and authentication.
- Firebase Tools v11 CLI used to manage a Firebase project
- AngularFire v7 Angular library for Firebase
- Express v4 Node.js framework
- Install dependencies using
npm i - Run
ng servefor a dev server. Navigate tohttp://localhost:4200/. The app will automatically reload if you change any of the source files. - In a 2nd terminal, cd to
/functionsand runnpm ithennpm run serveto install backend dependencies, create build file and start up Functions emulator - navigate to
localhost../api/databaseKeythe realtime database value will be displayed - Run
ng buildto build the project. The build artifacts will be stored in thedist/directory. Use the--prodflag for a production build. - Run
ng updateto update Angular
- functions
index.tsfunction to retrieve value from Firebase realtime database for key supplied
// get value corresponding to key supplied
app.get("/database_ref", (request, response) => {
const db = admin.database();
const ref = db.ref("database_ref");
ref.once("value").then((value) => {
response.send(value);
})
.catch((err) => console.error(err));
});- Firebase Cloud Functions can be used is a serverless framework that allows backend code to be run automatically in response to https requests and Firebase features.
- Status: Working
- To-Do: Add other functions and database key-values
- This project is licensed under the terms of the MIT license.
- Repo created by ABateman, email: gomezbateman@yahoo.com
