Reputation: 1
I am trying to deploy a delete function into the firebase cloud functions but then I get this error Error: Functions did not deploy properly
. I have installed all the dependences e.g firebase-tools. Some of the steps I went through setting up the project are in these:
This is the code I am trying to deploy:
const admin = require('firebase-admin');
const firebase_tools = require('firebase-tools');
const functions = require('firebase-functions');
admin.initializeApp();
exports.mintAdminToken = functions.https.onCall(async (data, context) => {
const uid = data.uid;
const token = await admin
.auth()
.createCustomToken(uid, { admin: true });
return { token };
});
exports.recursiveDelete = functions
.runWith({
timeoutSeconds: 540,
memory: '2GB'
})
.https.onCall(async (data, context) => {
// Only allow admin users to execute this function.
if (!(context.auth && context.auth.token && context.auth.token.admin)) {
throw new functions.https.HttpsError(
'permission-denied',
'Must be an administrative user to initiate delete.'
);
}
const path = data.path;
console.log(
`User ${context.auth.uid} has requested to delete path ${path}`
);
// Run a recursive delete on the given document or collection path.
// The 'token' must be set in the functions config, and can be generated
// at the command line by running 'firebase login:ci'.
await firebase_tools.firestore
.delete(path, {
project: process.env.GCLOUD_PROJECT,
recursive: true,
yes: true,
token: functions.config().fb.token
});
return {
path: path
};
});
Upvotes: 0
Views: 410
Reputation: 1781
As from the comments, running the following solved the problem
npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools
Upvotes: 1