I\'m working with firebase functions and arrived to hundreds of functions, and now it is very hard to manage it in single index.js file as shown in their lots of ex
You can pass the exports object to the function in groupFunctions.js, like this:
var functions = require('firebase-functions');
module.exports = function (e) {
e.onGroupCreate = functions.database.ref('/groups/{groupId}')
.onWrite(event => {
console.log(`A group is created in database named:${event.params.groupId}.`);
// some logic...
//...
})
}
Now, in index.js:
var functions = require('firebase-functions');
require("./app/groupFunctions")(module.exports);
The way it works is that modules.exports is a regular JavaScript object, so you can add new properties to that from wherever you want.