项目作者: AndrewJBateman

项目描述 :
:clipboard: Angular with Firebase Functions and express to access Cloud Firestore realtime database
高级语言: TypeScript
项目地址: git://github.com/AndrewJBateman/angular-firebase-functions.git


:zap: Angular Firebase Functions

  • 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

GitHub repo size
GitHub pull requests
GitHub Repo stars
GitHub last commit

:page_facing_up: Table of contents

:books: General info

  • 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)then Generate new private key that adds a json file to the user’s PC. The path to this access key file is referenced in the express server index.ts file
  • This is just a very simple example to demonstrate how a Firebase database function works

:camera: Screenshots

Screenshot

:signal_strength: Technologies

:floppy_disk: Setup

  • Install dependencies using npm i
  • Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
  • In a 2nd terminal, cd to /functions and run npm i then npm run serve to install backend dependencies, create build file and start up Functions emulator
  • navigate to localhost../api/databaseKey the realtime database value will be displayed
  • Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.
  • Run ng update to update Angular

:computer: Code Examples

  • functions index.ts function to retrieve value from Firebase realtime database for key supplied
  1. // get value corresponding to key supplied
  2. app.get("/database_ref", (request, response) => {
  3. const db = admin.database();
  4. const ref = db.ref("database_ref");
  5. ref.once("value").then((value) => {
  6. response.send(value);
  7. })
  8. .catch((err) => console.error(err));
  9. });

:cool: Features

  • 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.

:clipboard: Status & To-Do List

  • Status: Working
  • To-Do: Add other functions and database key-values

:clap: Inspiration

:file_folder: License

  • This project is licensed under the terms of the MIT license.

:envelope: Contact