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
Working code example:
file structure:
--firebase.json
--functions
--node_modules
--index.js
--package.json
--src
--groupFunctions.js
--authFunctions.js
--storageFunctions.js
index.js
file:
require('./src/groupFunctions.js')(exports);
require('./src/authFunctions.js')(exports);
require('./src/storageFunctions.js')(exports);
groupFunctions.js
file:
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...
//...
})
}
The full working code is located at https://github.com/malikasinger1/firebase-functions-with-typescript and it's written with cutting edge tech like typescript and webpack. You may use this as a boilerplate/starter.