Hi,
I’m using ReScript to work with Firebase functions.
I have two parts:
- A callable function defined in Node.js
- A frontend application calling the function in the browser.
The way Firebase works is that you can export functions from your index.js in Node:
import {onCall, HttpsError} from "firebase-functions/v2/https";
export const myAction = onCall(request => { return 42 })
And then the client can do something like:
import { getFunctions, httpsCallable } from "firebase/functions";
const functions = getFunctions();
const callMyAction = httpsCallable(functions, 'myAction ');
Notice that myAction needs to line up in both the server and the client.
So it is a bit of a magic string deal here.
Can I define my function name as a constant string in ReScript (in a shared file that both the client and server use)?
Using it on the client is easy, but can I somehow tell rescript that it needs to output my export const with the same constant name?