Skip to main content
This page walks through deploying the TMT Platform backend to Firebase Cloud Functions, configuring secrets, and running functions locally with the Firebase Emulator.

Prerequisites

Before deploying, make sure you have the following:
  • Node.js 22 — required by the engines field in package.json
  • Firebase CLI — install globally with npm install -g firebase-tools
  • A Firebase project on the Blaze plan with Cloud Functions enabled
  • A Cloud SQL PostgreSQL instance if you use any reporting or reconciliation functions
  • Billing enabled on your Google Cloud project
The package.json engines field pins the runtime to Node.js 22. Firebase will use this version when deploying your functions.

Deployment workflow

1

Install dependencies

Install all Node.js packages from the functions/ directory.
npm install
Key dependencies installed include firebase-admin, firebase-functions, @google-cloud/cloud-sql-connector, pg, stripe, seatsio, and axios.
2

Authenticate with Firebase

Log in to your Google account and select your Firebase project.
firebase login
Then link the project to this directory:
firebase use --add
When prompted, choose your project from the list. This writes a .firebaserc file that the CLI uses for all subsequent commands.
3

Set Firebase config secrets

The TMT Platform reads all sensitive credentials from Firebase Secrets at runtime. Set each secret with the CLI — you will be prompted to enter the value interactively.Seats.io
firebase functions:secrets:set SEATSIO_DEV_KEY
firebase functions:secrets:set SEATSIO_PROD_KEY
Banco Mercantil
firebase functions:secrets:set MERCANTIL_MERCHANT_ID
firebase functions:secrets:set MERCANTIL_MERCHANT_ID_TED
firebase functions:secrets:set MERCANTIL_CIFR
firebase functions:secrets:set MERCANTIL_CIFR_TED
firebase functions:secrets:set MERCANTIL_CLIENT_ID_IBM
firebase functions:secrets:set MERCANTIL_CLIENT_ID_IBM_PM
Banco de Venezuela (BDV)
firebase functions:secrets:set BDV_ACCOUNT
firebase functions:secrets:set BDV_API_KEY
Notifications
firebase functions:secrets:set NOTIFICATION_PHONE
Cloud SQL (PostgreSQL)
firebase functions:secrets:set CLOUDSQL_INSTANCE_CONNECTION_NAME
firebase functions:secrets:set CLOUDSQL_USER
firebase functions:secrets:set CLOUDSQL_PASSWORD
firebase functions:secrets:set CLOUDSQL_DATABASE
Never hardcode credentials in config/config.js or config/dbpostgres.js. The placeholder values ('-', 0) in those files are intentional. Inject real values only through Firebase Secrets.
4

Deploy all functions

Run the deploy command from the functions/ directory (or wherever package.json lives):
npm run deploy
After a successful deployment, the CLI prints the HTTPS endpoint for each function:
Function URL (my_function): https://us-central1-your-project-id.cloudfunctions.net/my_function

Deploying specific functions

To deploy a single function without redeploying everything, pass the function name to --only functions:
firebase deploy --only functions:function_name
To deploy multiple specific functions in one command, separate names with commas:
firebase deploy --only functions:exchange_rates,functions:create_client
Deploying individual functions is significantly faster during development. Use targeted deploys when iterating on a single function to avoid waiting for the full suite to upload.

Local development with the Firebase Emulator

The Firebase Emulator Suite lets you run Cloud Functions locally without deploying to Firebase.
1

Start the emulator

npm run serve
The emulator starts a local HTTPS server. Functions are available at:
http://localhost:5001/<project-id>/<region>/<function-name>
2

Open the Emulator UI

Navigate to http://localhost:4000 in your browser to access the Emulator UI. From here you can inspect function invocations, view logs, and browse emulated Firestore data.
3

Test a function

Call a function using curl or any HTTP client:
curl -X POST \
  http://localhost:5001/your-project-id/us-central1/exchange_rates
The local emulator cannot connect to Cloud SQL. Functions that call sqltmt() will fail unless you point config/dbpostgres.js at a local PostgreSQL instance during development.

Monitoring logs

View real-time logs from deployed functions using the Firebase CLI:
npm run logs
Filter logs for a specific function:
firebase functions:log --only function_name
You can also view logs in the Google Cloud Console under Cloud Functions > Logs or in Cloud Logging for more advanced filtering, alerting, and log retention.

Available npm scripts

The package.json defines the following convenience scripts:
ScriptCommandDescription
npm run servefirebase emulators:start --only functionsStart the local Functions emulator
npm run shellfirebase functions:shellOpen an interactive Functions shell for testing
npm startnpm run shellAlias for shell
npm run deployfirebase deploy --only functionsDeploy all functions to Firebase
npm run logsfirebase functions:logStream logs from deployed functions

Build docs developers (and LLMs) love