Gcp/Firebase/CloudFunctions/カスタムクラス
提供: 初心者エンジニアの簡易メモ
別クラス呼び出し
functions/index.js
exports.circle = functions.region('asia-northeast1').https.onRequest((request, response) => { const circle = require('./circle.js'); // require('circle.js')とか、require('circle')とか、require('/circle')の記述はだめだった。 response.send('The area of a circle of radius 4 is ' + circle.area(4)); });
functions/circle.js
var PI = Math.PI; exports.area = function (r) { return PI * r * r; }; exports.cube = function (r) { return PI * r * r * r; };
別function呼び出し
function sum(){ return 1 + 2; } exports.sum = functions.region('asia-northeast1').https.onRequest((request, response) => { response.send('sum ' + sum()); });