functions-samples | Collection of sample apps showcasing popular use cases | Cloud Functions library
kandi X-RAY | functions-samples Summary
kandi X-RAY | functions-samples Summary
This repository contains a few categories of samples:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Starts the users list of payment methods .
- determine if we are now in Firebase database .
- Check database connection .
- Create a firebase account .
- Report an error .
- creates message bookbook
- Search for a given query .
- Search for a certain typesenseenseLanguage .
- Blur an image
- Extract the user ID token from the Firebase request .
functions-samples Key Features
functions-samples Examples and Code Snippets
Community Discussions
Trending Discussions on functions-samples
QUESTION
I am creating an ImageAnnotator for a native iOS mobile app using Firebase Cloud Functions, following the Firebase documentation for the iOS client and Cloud Function. Yet upon calling 'annotateImage' client-side the error 'Unexpected token o in JSON at position 1' is returned. I am using XCode 13.
My client code:
...ANSWER
Answered 2021-Oct-20 at 15:05I was able to resolve the error by using the solution suggested here:
- Change the 'features' dictionary value of requestData to an array.
- Pass requestData as encoded string JSON to annotateImage().
But still the line
QUESTION
I would like to integrate cloud vision functionality into my firebase app without having to migrate my project to typescript at this time. All of my cloud functions are written in javascript. How might one translate the typescript example provided here (below for reference) to plain old javascript?
...ANSWER
Answered 2021-Oct-14 at 03:46I don't see any type annotations in the code you shared, so it looks like that plain-old JavaScript already. You should be able to paste it into your index.js
files and use it as is.
If you ever find a file that contains type annotations and you want to use it in a pure JavaScript setting, you can use a tool like this TypeScript playground to convert TypeScript to JavaScript.
QUESTION
So I have a Webhook that delivers a JSON payload to my cloud function URL.
Within that cloud function, what are my limitations for writing the JSON to my Cloud Firestore?
I can't dump my JSON payload all to one document within a collection, so I need to parse it all out to different fields.
So my cloud function will look something like:
...ANSWER
Answered 2021-Sep-23 at 19:06Technically there isn't any limit and as long as you stay in rate limits defined in the documentation you should be fine. If it's a single webhook that has all the data then you can write all documents in a single go. You can either use Promise.all()
or Batch Writes
(if writing a max of 500 documents).
QUESTION
I have done some googling and haven't found an answer to my question. I am following the tutorial for google firebase functions here and have copied index.js
exactly from the GitHub repository linked on the tutorial as well as copying the code in 'chunks' by following the tutorial and I get this error after running firebase deploy --only functions
error Parsing error: Unexpected token =>
which references this function:
...ANSWER
Answered 2021-Jul-20 at 08:47Async functions and await keyword were added in ECMAScript 2017. You need to set ecmaVersion
to 8
in your ESLint config.
QUESTION
I'm trying to build a Patreon-like app: A creator creates an account where users can then subscribe for some price.
I have gotten to the point in my code where I now need the user to add his bank info into stripe so he can receive funds. I have come across questions like this, and this, but neither shares any information on how a user can input his bank info on the client-side (they only deal with the backend).
The connected accounts are Express accounts.
How do I make the user add banking information on the client-side?
I have been recommended this stripe page but it does not show how to allow a creator to input banking info on client-side. I have also implemented the example backend code from firebase and updated it for my specific case.
Update:
I've also come across this page about Managing bank accounts and debit cards but it appears to be for custom accounts not express.
...ANSWER
Answered 2021-Mar-30 at 03:35Stripe uses a hosted onboarding page for Express accounts. It's basically a form hosted on a Stripe domain that handles all the common onboarding requirements (e.g. verification documents and bank account details) needed.
Once the user has filled everything in they are redirected back to your site/app. In other words you don't really have to worry about collecting bank details client side, Stripe does it for you: https://stripe.com/docs/connect/express-accounts
QUESTION
I've copied the firebase stripe GitHub example index.js and have been fixing the errors which pop up from hosting the code in my index.ts (typescript) file. The error I have left is the following:
Expected 2 arguments, but got 1.ts(2554) index.ts(54, 112): An argument for 'arg1' was not provided.
It's about this line (there are multiple instances although this should not matter to the solution):
...ANSWER
Answered 2021-Mar-21 at 06:35I've not tried this but as per the typescript hint. this function accepts 2 arguments.
arg0
of type object which has propertyerror
of typeany
.arg1
of type object which has propertymerge
of typeboolean
orundefined
.
So you need to call it something like this if setting error.
QUESTION
In express
you can add middleware such as app.use(cors())
which adds it to all of the endpoints, however I can't find something similar in firebase examples. Here is the example (see below) of how to apply it in every function. However I want to apply the middleware (cors or other) globally, as I have many functions.
ANSWER
Answered 2021-Mar-12 at 00:47Use currying to create a handler, you have to repeat it across all the functions, but it's easier than writing the middleware each time:
QUESTION
I have a rest api and this is the end point:
...ANSWER
Answered 2021-Jan-11 at 12:00Cloud function triggers firestore events only after a change has been made to the document. In your case it might be an additional overhead to update the document and revert back when the user is unauthorized to do the action.
Your snippet is better in terms of not having the overhead, but the problem is anyone can fake the req.user.Id
to match the myUserId, thus not prescribed to so.
The solution can be is what is mentioned in the document you have posted, to authorize the user with the token. So
You get the user.id from the authorized firebase token (passed in the request header)
Now you can match the id with myUserId to determine whether the user is authorized to perform the action.
const decodedIdToken = await admin.auth().verifyIdToken(idToken); req.user = decodedIdToken;
An alternative approach to do at database level is to have rules (instead of triggers) as explained here.
QUESTION
I am trying to integrate Stripe payments on my webapp using Firebase. I have cloned the code from the repository here: https://github.com/firebase/functions-samples/tree/master/stripe and have followed the documentation here: https://firebase.google.com/docs/use-cases/payments
From reading the documentation, I assumed that when a customer signed in through firebase authentication, their details would be added to a stripe_customer collection in the firestore. I realised this wasn't the case, and manually added a user to test the save card functions. Then I received the following error : "Invalid value for stripe.confirmCardSetup intent secret: value should be a client_secret string. You specified: undefined"
I have a blaze plan for firebase and have configured. From following the steps in the documentation, I assumed this would be working. I'm sorry this question is so vague, but it seems at every corner I'm getting another issue. Is there something very obvious I am missing that is stopping this code from working? I am trying to implement this for a friends business as a favor, and am getting really confused with Firebase. I am coding in Angularjs. Would greatly appreciate any help on this!
This is the code for the function to create a customer
...ANSWER
Answered 2020-Nov-12 at 22:39The error you've supplied (below) implies that the key in your config isn't been pulled into your code. If you're running this locally you need to run the below any time you change your functions:config values.
QUESTION
I used this code sample here, in which a snippet is attached:
...ANSWER
Answered 2020-Nov-05 at 18:11The code you're showing here is only showing the definition of validateFirebaseIdToken
, but not where it's being used. In the linked example, you can see it's being applied to the entire app:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install functions-samples
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page