I have to load dotenv config and admin.initializeApp methods in every function file. Precisely, I have to write below code in every file:
import { config } from "dotenv";
import * as admin from "firebase-admin";
config();
if (!admin.apps.length) admin.initializeApp();
Is there a way to write this code only in index file and all functions get access to env variables as well as app get initialized in all functions.
Instead of index, why not have a single separate module to include that exports the shared data to use wherever these are needed?
@DougStevensonSo, I have extract it in function and call it on every firebase function. It is not possible to write this code only once in index. Right?