I'm initializing admin in my root functions file(index.js).
if I create a limiter object in root index.js file no error is thrown. However, in my case i'm trying to set a limiter in subfolder file i.e (api/emailsend.js)
If i try to create rateLimiter outside of the function and outside of root file where I initialized admin I the following error:
Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.
the error is due to me calling admin.firestore() inside this libs FirebaseFunctionsRateLimiter.withFirestoreBackend function. As it seems the admin.initializeApp({}) has not completed when rateLimiter is creation is invoked .
I'm initializing admin in my root functions file(
index.js
). if I create a limiter object in root index.js file no error is thrown. However, in my case i'm trying to set a limiter in subfolder file i.e (api/emailsend.js
)If i try to create rateLimiter outside of the function and outside of root file where I initialized admin I the following error:
Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.
the error is due to me calling
admin.firestore()
inside this libsFirebaseFunctionsRateLimiter.withFirestoreBackend
function. As it seems theadmin.initializeApp({})
has not completed when rateLimiter is creation is invoked .Any suggestions?