I want to write a custom library in node, and I would like to include it in my cloud functions. Since this is generic code, I would like to use it in all my Cloud functions.
What is the best way to write a shared code library and access them through several cloud functions.
For example, let's say I have two cloud functions, functionA and functionB.
I have a javascript node file called "common.js" that has a javascript function that I would like to provide both functions and functions.
exports.common = { log: function(message) { console.log('COMMON: ' + message); } };
So, in function A, I would like to require this file and call "common.log ('test');".
I see this as the easiest question, but I honestly can't find the answer anywhere.
Any help would be greatly appreciated. This is literally the only thing that prevents me from using GCF as a way to develop code now and in the future!
source share