index.ts
import * as functions from 'firebase-functions';
export const testFunction = functions.https.onCall( async (data, context) => {
const uid = context.auth && context.auth.uid;
const message = data.message;
return `${uid} sent a message of ${message}`
});
Callable functions make it possible to call HTTP cloud functions with the user’s Firebase auth context. This can dramatically simplify our code because it means we no longer need to manually validate auth headers in our cloud functions.
command line
firebase init hosting
firebase deploy --only functions
firebase serve