Skip to content

IDEMSInternational/open-app-builder-functions

Repository files navigation

Open App Builder Functions

Image: License Image: Node Version

Overview

This repository contains deployable Firebase Functions that provide backend functionality for the Open App Builder ecosystem.

Deployable functions can be found in ./src

Preprequisites

  • Node.js (version 22 recommended to match Firebase deployment)

It is recommended to use a Node version manager such as:

QuickStart

  1. Setup Environment Variables
cp .env.example .env
  1. Install Dependencies
npm install

Running Locally

Use start command to start the Firebase emulator suite and serve functions (with live-reload on change)

npm run start

Testing Endpoints

Once running, a list of available function endpoints will appear in the console.

You can trigger functions by sending requests to the endpoints using any REST client.
Recommended free and open-source options:

Example request (VS Code REST Client)

my-request.http

POST http://127.0.0.1:5001/test/us-central1/groupJoin
Content-Type: application/json
Authorization: Bearer <your_token>

{
"example": "data"
}

Open the file in VSCode and click the Send Request button that appears

Example request (using cURL)

curl -X POST http://127.0.0.1:5001/test/us-central1/groupJoin \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_token>" \
  -d '{"example": "data"}'

Deploying to Production

1. Review Environment Variables

Ensure all production environment variables are set as expected in ./env.

2. Link Firebase Project

Register a Firebase project (should be created in advance using the Firebase Console):

npm i -g firebase-tools
firebase login
firebase use --add

This will prompt you to select a project and specify an alias (useful for deploying to multiple projects).

See all available projects in .firebaserc. The active project can be changed via:

firebase use {alias}

3. Deploy

Deploy all functions:

firebase deploy

Deploy specific functions:

firebase deploy --only functions:myFunction1,functions:myFunction2

Creating Functions

See the Firebase Functions documentation for guidance on creating and structuring new functions.

Managing Seed Data

When running locally, firestore emulators will populate any data located in the test/seed-data directory on startup, but will not persist data across sessions (cleans up on exit)

If additional seed data should be included for all emulator runs, the current state of emulator data can be exported via

npm run emulators:export

Note that the data will be exported as a set of LevelDB files, which cannot be read as plain text (designed for internal use). As such changes to these files will have to be reviewed by viewing within the firestore emulators.

Contributing

Contributions are welcome! Please open issues or submit pull requests for improvements or new features.

About

Cloud functions for use with Open App Builder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors