Library
Firebase Functions
A single Firebase HTTPS function that exposes one clear route per EmailsDone transactional template.
The Firebase wrapper is a deployable backend function around the emailsdone npm package. It keeps your EmailsDone API key in Firebase Secret Manager and gives Firebase apps simple routes such as /auth/password-reset, /auth/verify-email, and /billing/payment-failed.
How it works
- Deploys one HTTPS function named
emailsdone. - Hosts an Express router inside that function, so you do not deploy one function per template.
- Injects the correct EmailsDone
templateIdinternally for each route. - Uses Firebase Secret Manager for
EMAILSDONE_API_KEY. - Supports explicit CORS origins and optional Firebase App Check verification.
The generated wrapper currently documents 51 template routes.
Install
npm install -g firebase-tools
git clone https://github.com/emailsdone-dev/emailsdone-firebase.git
cd emailsdone-firebase
npm install
If you are adapting the sample to a new Firebase project, run firebase init emulators and keep the Functions emulator enabled.
Run locally
Create local emulator config:
cp functions/.secret.local.example functions/.secret.local
cp functions/.env.local.example functions/.env.local
Set your local secret in functions/.secret.local:
EMAILSDONE_API_KEY=your_emailsdone_api_key_here
Start the emulator:
npm run dev
Test a route with cURL:
curl -X POST http://127.0.0.1:5001/demo-emailsdone-firebase/europe-west2/emailsdone/auth/password-reset \
-H "Content-Type: application/json" \
-d '{"to":"user@example.com","data":{"actionButton":{"url":"https://app.example.com/reset"}}}'
Request body
Every generated route accepts the same wrapper shape. Required fields inside data depend on the selected route.
{
"to": "user@example.com",
"data": {
"actionButton": {
"url": "https://app.example.com/reset"
}
},
"templateVersion": "v1",
"from": "support@example.com",
"fromName": "Example App",
"replyTo": "support@example.com",
"idempotencyKey": "password-reset-user-123"
}
Deploy
firebase login
firebase use <project-id>
firebase functions:secrets:set EMAILSDONE_API_KEY
npm run deploy
Use EMAILSDONE_ALLOWED_ORIGINS for explicit browser CORS origins and set EMAILSDONE_REQUIRE_APP_CHECK=true in production when app clients call the function.
OpenAPI
The generated wrapper OpenAPI file describes every Firebase route, request body, required template field and response type.