unable to deploy functions to Firebase

Viewed 58

I am trying to deploy Firebase Functions from xcode using this tutorial - https://firebase.google.com/docs/functions/get-started. This is my index.js -

    'use-strict' 
 // The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
  const functions = require('firebase-functions');

   // The Firebase Admin SDK to access Firestore.
     const admin = require('firebase-admin');
    admin.initializeApp();

   // Take the text parameter passed to this HTTP endpoint and insert it into
  // Firestore under the path /messages/:documentId/original
  exports.addMessage = functions.https.onRequest(async (req, res) => {
 // Grab the text parameter.
 const original = req.query.text;
 // Push the new message into Firestore using the Firebase Admin SDK.
 const writeResult = await    admin.firestore().collection('messages').add({original: original});
   // Send back a message that we've successfully written the message
   res.json({result: `Message with ID: ${writeResult.id} added.`});
   });

    // Listens for new messages added to /messages/:documentId/original and creates an
 // uppercase version of the message to /messages/:documentId/uppercase
  exports.makeUppercase = functions.firestore.document('/messages/{documentId}')
   .onCreate((snap, context) => {
    // Grab the current value of what was written to Firestore.
    const original = snap.data().original;

    // Access the parameter `{documentId}` with `context.params`
    functions.logger.log('Uppercasing', context.params.documentId, original);
  
    const uppercase = original.toUpperCase();
  
     // You must return a Promise when performing asynchronous tasks inside a Functions such as
    // writing to Firestore.
    // Setting an 'uppercase' field in Firestore document returns a Promise.
    return snap.ref.set({uppercase}, {merge: true});
    });

After I run either of the commands "firebase deploy --only functions" or "firebase deploy --only functions:addMessage", it shows message -

"✔ Deploy complete!

I don't see the functions deployed in the firebase console and it shows message - Project Console: https://console.firebase.google.com/project/testpro-92351/overview Apples-MacBook-Air:Fireupgoodsa apple$".

but I expect to see "Function URL (addMessage): https://us-central1-MY_PROJECT.cloudfunctions.net/addMessage".

Note that:-

  • My app name is "Fireupgoodsa" under the project "testpro-92351".
  • I have activated the blaze plan.
  • Firestore is working fine.

What am I missing out on ?

I have also other question, slightly related - I am trying to link Firestore to Stripe-Payments Is it necessary to deploy functions to Firebase ?

Thanks,

0 Answers
Related