0

So I am using firebase functions, as my API request with some functions doing some work, Right now I have 1 'index.ts' file and all of my functions inside (14 functions) there with this signature:

export const $function1 = functions.region(#region).runWith({ memory: '512MB' }).https.onRequest

export const $function2 = functions.region(#region).https.onCall(async (data, context) => {

Now my question is about organize this 'index.ts',

Some of my https requests verify token and check for valid body request,

What is the best way to organize this 'index.ts' file?

How exactly I am exporting it from files in this folder without initialize the admin sdk every time?

I am trying to make this folder organize as I can as in the future I need to add more and more functions..

Thanks for the help!

1 Answer 1

2

This is really a personal preference but the recommended way to organize functions by Firebase documentation is to write all your functions in their own files, export them then initialize them all in one index.ts file[1]. You can also group your functions depending on their purpose like auth or logging ...etc then export them to one index.ts file. For more info, check the documentation I have shared but as I said, you can always organize them in your own way.

[1]https://firebase.google.com/docs/functions/organize-functions

Sign up to request clarification or add additional context in comments.

1 Comment

Very helpful ! I didn't find this documentation when I searched for it, Thanks you very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.