Dashboard Hero
  • Scope
  • Introduction
    • Meet and greet
    • Requirements(tech)
    • Requirements(user)
  • Setting up
    • Developing locally
    • Deploying
  • Basics
    • Scss
    • Javascript
    • Svelte framework
    • vs React vs Angular vs vue.js
    • Rollup(and rollup.config.js)
    • NPM(and package.json)
  • Project structure
    • Overview
    • Git version
    • Folder version
  • Architecture
    • DRY vs WET programming
    • Basic
    • Extended
  • Components
    • Component lifecycle
    • Passing data between components
    • Buttons
    • Charts
    • Grids
    • Search bars
    • Other inputs
    • Dialogs
    • Dropdowns
    • Gauges
    • User management pages
  • Backend
    • Firebase cloud functions
  • Data sources
    • Firebase
    • MongoDB
    • *SQL sources
    • GraphQL
  • User management
    • Log in
    • Register
    • Forgot pass
    • Custom flows
    • Others
  • State control
    • Redux
    • MobX
    • Saga
  • Dashboard: a full project
    • Overview
    • Layout
    • Routing
    • Removing/adding pages
    • Deploying
  • Roadmap/tutorial
    • Introduction - building your own app
    • 1. UI - HTML&CSS
    • 2. Data sources(+testing)
    • 3. Defining and using existing components
    • 4. User management
    • 5. Go live!
  • Troubleshooting
    • Can't run the project
Powered by GitBook
On this page

Was this helpful?

  1. Backend

Firebase cloud functions

Put very simply, Firebase cloud functions are pieces of javascript code that reside on the server and run each time a request from the client is made.

Each such request has meta information - context - from which we can extract authentication information, such as the user id. Each request also has a data object, to which we can pass information from the client.

Here is how one can call a cloud function from the client:

firebase.app().functions().httpsCallable('inviteUser')
.inviteUser(
    { email: email, fullname: 'John Doe', userId: generateUUID() }
);

And here is how the function responding to this user call looks like:

exports.inviteUser = functions
	.https.onCall(async (data, context) => {
		let company = await getCompanyNameFromUserId( context.auth.uid )
		const { fullname, email, userId } = data;
	  // do the wiring with the vars extracted from data
	  // create user account, add user to company, send verification email
		...
		return ...
		);
		
	});
PreviousUser management pagesNextFirebase

Last updated 5 years ago

Was this helpful?