Organize Cloud Functions for Firebase

后端 未结 4 556
小鲜肉
小鲜肉 2020-12-17 09:15

What is the best practice to organize all our Cloud Functions for Firebase?

I see from the sample GitHub repository that all functions reside in a single index

4条回答
  •  再見小時候
    2020-12-17 09:50

    This is a great question and something I have recently been looking for. I found this great strategy from Tarik Huber: Organizing your Firebase Cloud Functions. It's his take on his own thoughts and a few other contributors in this area.

    He organizes his functions based on their usage and type (i.e. trigger, Http, etc) into a folder structure. The index.js code iterates thorugh the structure and imports the functions in a very structured and succinct way. It not only allows the developers to simply add new functions in a well understood structure but they don't have to manually manipulate the index.js file, and it deploys the function names in Firebase according to the structure as well.

    Definitely check it out.

提交回复
热议问题