From 804eeb2d2f467ba01b1911fb0cdcf84e5db7aab5 Mon Sep 17 00:00:00 2001 From: Justin Grayston Date: Tue, 2 Oct 2018 12:29:30 +0100 Subject: [PATCH] Resolve function deploy error Removes `Functions.config().firebase` as this has been removed since beta v1 made breaking changes. Also moved the db init, to after Firebase init so DB info has been passed in. Closes #3 --- functions/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/index.js b/functions/index.js index cbbe112..4984f0c 100644 --- a/functions/index.js +++ b/functions/index.js @@ -30,8 +30,8 @@ const predictionClient = new automl.PredictionServiceClient(); // Firebase libraries const functions = require('firebase-functions'); const admin = require('firebase-admin'); + const db = admin.firestore(); -admin.initializeApp(functions.config().firebase); function resizeImg(filepath) { return new Promise((resolve, reject) => { @@ -68,7 +68,7 @@ function callAutoMLAPI(b64img) { reject(err); }); }); - + } exports.callCustomModel = functions.storage.object().onFinalize(event => { @@ -81,12 +81,12 @@ exports.callCustomModel = functions.storage.object().onFinalize(event => { return resizeImg(destination); } else { return destination; - } + } }) .then(() => { let bitmap = fs.readFileSync(destination); let data = new Buffer(bitmap).toString('base64'); - return callAutoMLAPI(data); + return callAutoMLAPI(data); }) .then((response) => { let predictions = {}; @@ -115,4 +115,4 @@ exports.callCustomModel = functions.storage.object().onFinalize(event => { .catch((err) => { console.log('error occurred', err); }); -}); \ No newline at end of file +});