Getting Started with Cloud Functions for Firebase using TypeScript - Firecasts
Вставка
- Опубліковано 7 вер 2024
- Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Watch this video to get started writing functions using TypeScript and deploying them with the Firebase CLI. Check out the links below & subscribe to our channel for the latest Firebase videos.
Firebase console → goo.gl/mgj8Sc
Install node.js → goo.gl/D33cb2
Cloud Functions documentation → goo.gl/BwdRcY
Codelab → goo.gl/DvWbAB
Sample code → goo.gl/jPLjJd
Using TSLint with TypeScript → goo.gl/gg65KD
Cloud Functions for Firebase - Tutorials → bit.ly/2M2ZBcE
Subscribe to the Firebase channel → bit.ly/firebase2
Terrific walk-through! It seems scary when you just watch it but if you follow step-by-step, it becomes quite easy 👍
Your mvvm tutorials helped us get 100% for my college Mobile Development course
Ty my guy
@@MrMrbannanapants You're welcome brother
WORD 😀
I was plumber, after watching this video I became senior Node developer
😂
🤣 Firebase should pin this comment!
I became a computer too
Maam I Do My Own Plumbing.
This is the best presentation on Firebase i found so far! Thank you Sir! Unfortunately, none of the current videos (as of Feb 2024) from your colleagues at Firebase team come even close. Please come back and post more videos on Firebase, Google Cloud, and Vertex AI!
Sir, I first interacted with you in Stack Overflow. I really liked your answers there. You were quite helpful. But, I didn't know about your UA-cam videos. The explanations are really good. Thanks for helping amateur developers like us.
Can't tell you in words. How easy this tutorial made for me to work on this.
Thanks doug!! Im glad you kept it very simple. Some of us are rebels and wanna just jump in.
Getting started with Firebase is so quick and easy, I feel right at home. Thanks for the video, Doug!
I was impressed how well you explain things.
Glad you found this video useful!
Doug Stevenson definitely did! Just finished looking into TypeScript as I haven’t before. And because this video got me looking, I’m definitely transitioning to TypeScript from here on out for everything, including my Cloud Functions. Thank you Doug.
Indeed, very well paced and explained
You are awesome explaining, I already subscribed to your channel hoping you'll start vlogging lol
Thanks Doug, this tutorial is pure gold. Easy & simple to follow. I set my first functions in several minutes. Thank you!
For linux users, I would suggest to install NVM first, then install npm to avoid to "sudo npm install PACKAGE"
Thank you Sheldon Cooper
haha
Mindblowing, really enjoy Firebase products. The only problem I had was with my 'deploy' command as my .js file was not built automatically and I was receiving an error. I had to run *tsc --watch* in my other bash terminal to built the sources automatically in the background after every change made in the code. Great job Firebase team!
how to solve this error (Error: Your project fir-c04d1 must be on the Blaze (pay-as-you-go) plan to complete this command. Required API cloudbuild.googleapis.)
This was exactly what I needed, perfect pace for me thank you!
Excellent presentation style.
For anyone else who was stuck at about 8:08 with deployment, remember to save otherwise it won't send you a link :)
This actually helped me was puzzled for a second there😆
Thnx man! It was helpful
I did save but still getting this error:
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@@victoravr10 try this "npm install firebase-admin@8.6.0 firebase-functions@3.3.0"
Wow it has evolved a lot, I really like, I hope you guys publish more stuff like this.
Do we reaally need a blaze plan for this? I don't even have a credit card :'-( . Just when I thought I found the perfect solution
for temporarily you can change node version by this
"engines": {
"node": "8"
}
But in March 2021 it will be forced to use node 10 :( sadly
Doug, at 1:48 you mention more languages will be supported in the future. Is Dart one of those languages? It'd be great for the mobile app to be developed in Dart (Flutter), and the server-side code to be in Dart too (Firebase + Cloud Functions)
Thanks for sharing this, I got stuck while using express with this, but later it works +1
Hint: If your "firebase deploy" gets stuck somehow, check it out whether you are not behind a proxy. I lost some hours on that today before I notice the issue was on the proxy after hotspoting a wifi network from my mobile phone.
we need more videos like this. Awesome
Kudos. Well Done. One of the best I have seen (of zillions), any chance they could get you on the Angular team :)
Thanks! But I'm Firebase all the way. Well, for the foreseeable future. :-)
Any chance you can specify (anywhere in the documentation) how to run firebase init on a new project (when you already have a default)?
This is so good, why didn't I find this earlier!
why didn't you tell us about the feature where the [firebase init] command stumbles out with [Error: An unexpected error has occurred.] if there are no pre-existing firebase projects? (my firebase version 5.1.1)
Great tutorial! Too bad the video isn't updated to show the new logger.
If you have Node etc already installed and you understand what all this is about, and you need to just skip to the main instructions, go to 3:40
Sir, Please conduct a workshop on Firebase in Panjim-Goa. Please
src/index.ts:1:1 - error TS6133: 'functions' is declared but its value is never read.
1 import * as functions from "firebase-functions";
Explained very well. Thank you for tutorial
You mentioned other languages support is coming soon. Waiting for GO !
I am having lots of missing Babel modules, when doing firebase deploy, like this one:
../node_modules/@types/babel__core/index.d.ts:10:34 - error TS2307: Cannot find module '@babel/core/node_modules/@babel/generator'.
Could you guys do a course on progressive migration of exisiting Apps / users / data etc from real time database to firestore? Would be very handy to see some best practice guides of this migration. Thanks!
Thank you so much, Greetings from Mexico
Very helpful and well explained. Thank you :)
I've installed firebase-admin, and firebase-functions in my project. However, I get the error that 'firebase-functions' not found. I find it in the package.json files its in the node-modules directory. Any ideas as to why it's not found? This also makes it impossible to deploy the function. Any help is appreciated!
@04:03 'firebase login' did not do the trick for me. I got a 'login: ' where every password I've tried didn't work. Then I found in stackoverflow that you can do ' firebase login:ci ' this will give you a link in which if you 'ctr +' click it will open a new tap in your browser where you can choose the google account you want to use to log in to your firebase account. Choosing one will authenticate you and give you a token to login on a CI server.
great intro, was quite overwhelmed, still curious on 'how do i call this from my react app that is linked to a web app on firebase using firestore etc' can i put my function project with my web app project? or would i have two separate projects? and how do i import that into my app, maybe this is covered somewhere and I just have to keep looking :)
How can I get functions with routes like for example client/ or client/{id}........ and also still have the function list of end-points on the firebase console ?
Thanks for this tutorial! It's awesome
Is there any tutorial for sending push notifications in cloud functions using typescript?
Thx for the videos btW!
What about that tut? Did you find one yet?
This can help you
i think so,
ua-cam.com/video/I6p-kYOALbE/v-deo.html
Hi Doug, I have followed through your set up video and everything went fine until I had to run 'firebase deploy' and keep getting an error src/index.ts:1:1 error ts6033 'functions' is declared but its value is never read. I have tried everything and even set up a new project but still get the same problem. Do I have to import anything into my project (in xcode)? Your help would be appreciated.
Thanks
Chris
stackoverflow.com/questions/47756264/cloud-functions-firebase-cli-predeploy-error-typescript follow the last answer. This worked for me. But I keep getting a server error. It's probably related to my internet
I'm sure there are lots of legit reasons to get this error but I got it for a really dumb reason: I hadn't saved my typescript file after I uncommented the code.
why doing it in typescript when there so few examples to find about sending a FCM push notification from a Cloud Function... I didn't find any
Is it possible to have a document of functions written in the Python environment and another document of functions written in the node.Js environment using typescript for the same firebase project?
Does using the url generated let any function inside run regardless of get or post request? I am confused. I think yes. If we need dynamic code to run then post just helps with the data. Am I right?
hi I can will change later this configurations? sorry bad english
Can I run ANY function inside the function by the generated url? Does it not depend on get or post? In my understanding, yes. But if thefunction inside uses any dynamic data, we use post. Am I right?
i have latest versions of node,npm and firebase.. everything works fine but in the end those files into my directory aren't created.. but i don't get any error or something..
Looking for Documentation
Is it possible to use "firebase init functions" in a non interactive way ?, I can find docs , and Im experimenting with CI/CD deployments
Excellent video Doug
Thanks -very clear explanation
Hi Doug, would be much helpful to have a short tutorial on setting up cloud functions for local testing. Many thanks!
Yes, please!!!
Is anyone getting *Error: Forbidden Your client does not have permission to get URL /200 from this server.* invoking their cloudfuncions? Thanks.
Bro, go to the firebase console console.firebase.google.com in the functions and copy that url to acess.
This is so helpful, thanks 👍
Hi ,I wrote a cloud function where i will be pushing the signed url of the image file in firebase storage to firebase database, and I want to download that image into my external storage of my app, So will teh signed url will work do i need to go download url, could someboady help me on this,,,
Great Tutorial! I follow your video and works well. Now I would like to start another project to use cloud function. Do i need to run firebase init again in terminal? Will it overwrite the functions of my previous project?
Hello, how can i use the hook to add firebase to an existing web application written in ts? Thanks and greetings from Colombia.
When I add something to the VS Code editor, the browser link doesn't update unless I type "firebase deploy" but in this video he doesn't deploy when he adds the log. Am I missing something?
i got an error which says:"" Cannot run login in non-interactive mode. See login:ci to generate a token for use in non-interactive environments. ""after i input the command firebase login ... help
great video, thanks. Doug!
Someone know what tools they use to create this kind of videos?
Shouldn’t Dart be easy for you to add as a language, since it also compiles to Javascript? For those using Flutter it would be amazing, and it’s also easier for those coming from Android/iOs to learn Dart instead of Typescript.
TypeScript is supported by a transpile command in a predeploy hook in the Firebase CLI. You could certainly set up the same thing for Dart for yourself, since the predeploy hooks are just configuration in your project's firebase.json.
firebase.google.com/docs/cli/#predeploy_and_postdeploy_hooks
good day, is this still available for spark plan?
Really nice explanation. Thanks :)
How to structure project(multiple files) in firebase cloud functions using typescript ?
Please add Python Support from the firebase console. There is a large Python community and Python Support is much appreciated!
Unfortunately... cloud function not support node V.8.... some frameworks it's hard to run...
Dear sir i am suffering into a problem with firebase realtime database when i write into database after successfully write data the activity has restart automatically and start MainActivity my whole project behave like this i was tried much efforts but till i didn't find the solution i don't know the problem what happen
There is already a python runtime on cloud platform can I now use python to write functions and actually is there any documentation for that ?
Excellent tutorial
please sir help me to out from this problem why activity restart after writing to firebase realtime database
I've an error while initializing functions how to rectify it
HTTP Error: 403, The caller does not have permission
use sudo before command
Great video Doug. I have a question #askFirebase, I have a project with 2 real time databases (blaze plan), I've already developed cloud functions for one of the DB, but these functions does not work on the other DB. How can I deploy the same functions for both DB? I don't know where to choose which DB will be affected by the functions.
Thank you for your help
Doesn't work the npm dependencies will not install
This is definitely impressive!
-bash: firebase: command not found
this error is what I get after any firebase command
stackoverflow.com/questions/23645220/firebase-tools-bash-firebase-command-not-found
Impressive tutorial
Hello am new to Firebase am working on a project in Ionic were i need to create App which has Articles and users can create Article and be able to comment on other users Articles need Help Here......
For anybody else lost at 5:32, this explains what to do: stackoverflow.com/questions/29971053/how-to-open-visual-studio-code-from-the-command-line-on-osx
running "firebase init" gives me "command not found". what do i do?
while installing dependency with npm.I am getting an error
Very clear explanations but wouldnt be more appropiate to use types for request and response parameters? With a strict Typescript configuration in tsconfig.json it could be throw a compilation error if I'm not wrong.
The types of the request and response parameters are inferred by the TypeScript compiler, given what it knows about the firebase-functions module. You can see what it thinks they are by hovering the mouse over them. There's no need to give them explicit types in this case.
Great. I guess the function is defined elsewhere in a type file. I mentioned it because it's common compilation error I use to have. Great stuff Firebase functions by the way!
Pretty much all types for libraries are defined in dedicated files. They're usually found in .d.ts files in the library distribution. In VS Code, if you command- or control-click on a symbol in your code, it should take you off the the definition of that symbol in whatever library defines it.
Yes, I know. function.https.onRequest() must be defined in one of the Firebase definition files with the parameter types. It is perfectly clear now, thanks. Firebase + Typescript is awesome, almost like programing server side in C# or Java.
Error: functions predeploy error: Command terminated with non-zero exit code4294963238 %RESOURCE_DIR%%RESOURCE_DIR%%RESOURCE_DIR% ?????
First deploy doesn't work? = . =....????/ what ?
At the time of installing "npm install firebase-admin @ latest" I got this error: npm ERR! Unexpected end of JSON input while parsing near '...- types ":" 0.1.1-canary', help!
YT comments might not be the best place to get your problem resolved. There are other support options available that are likely more helpful and provide and better place to explain what's going wrong. firebase.google.com/support/
Just a guess, try using sudo... it doesn't seem to be a permission issue but hey, it doesn't hurt to try.
ATM I only really know Java but I want to use Cloud Functions for my App. This Video suggest I should learn TypeScript instead of JavaScript. Why? What are the differences and what is easier to learn coming from Java?
TypeScript is entirely enhancements upon JavaScript. It takes future features of JavaScript that haven't been implemented, and adds a static typing system to it. You can simply write JavaScript in your TypeScript code if you want (all JavaScript is valid TypeScript), then adapt to use TypeScript as you see fit.
@Doug when GraphQL sir ??
I personally like writing in TypeScript. It gives lots of feedback via the IDE if you use it as it's meant to be used. On the plus side, you can pretty much write plain JS if you like as well. All it does really is allow you to define your objects to adhere to a strict blueprint via interfaces (interface are somewhat of a misnomer as they are just blueprints which your objects and classes have to adhere to). For instance, if I set the type of a property to an array of pizzas but I accidentally try to throw in a pizza then I'll get an error in the IDE. Or if a property is supposed to be a string but I'm trying to set it as a number I'll also get an error in the IDE - saves coders from stupid mistakes and makes sure your code is consistent. Look it up, spend about an hour or two with an open mind and decide for yourself.
cool. thanks for concept
You told about adding new languages. Is Kotlin support high on the list and being worked on? Should we expect Kotlin/JS or Kotlin/JVM?
I'd like to play with Cloud Functions before starting a serious project, but I don't want to invest time learning TypeScript & JavaScript when Kotlin, my preferred language which I use daily may get support right around the corner.
#AskFirebase
Doug why are you using the exact same words as Jen? 🤔
Tsortanidis Christos I noticed that too! I think they are reading from the same script.
I actually wrote the first script, Jen read it last year, then I adapted that script here. Totally lazy. :-)
a lazy dev is a good dev. :D
Nice introduction, thanks for that :)
Is there a way to really debug the functions code, like with breakpoints and stuff?
I know we have that experimental shell, but can we somehow attach a debugger?
It's possible to to do today, but it's not very straightforward to set up. The Firebase team is looking into ways to make step-through debugging easier for local testing!
Thanks for the fast response. Looking forward to it :)
am unable to Create a Function for this?
Hi, I did exactly this -> firebase.google.com/docs/functions/callable for my swift ios app and it didn't work. Nothing more or less. The callable function did not even made a call to the callable function in cloud.
Later i found out debugging objective-c code (sucks), that the user must be authenticated before you can make a callable call to cloud functions from your iOS app. Please add this kind of important knowledge to docs!
Now that we have tensorflow.js :P Is it a good idea to use tf.js inside cloud functions for training/predicting ?
To me it would seem like using Cloud Functions for AI seems backwards. If you need a specific implementation maybe it's best to run your own server or find a service catered to this like Google Cloud AI. I've always understood that Cloud Functions are just for quick backend processes which you don't want running on the client side.
Does your training requires to be public ? Does your model fits in browser ? Did you consider Cloud Auto ML, that handles both training & predicting ?
Why is there a firebase sticker on the middle of your laptop?
I had watched some of Jen's videos on Google cloud functions for firebase on this channel a few days ago. I wanted to revisit those again as I found them really helpful but it seems like they have been taken down. Any particular reason for that?
Just the other day, the functions SDK version 1.0 was released, and it changes APIs in a way that breaks existing code on upgrade. That makes all the old videos obsolete, because they all talk about the old APIs. All that information is being recreated into new videos and documentation. To get your code up to date, be sure to read the migration guide here: firebase.google.com/docs/functions/beta-v1-diff
Thanks for the information Doug!
Thank you !
Helpful!
Glad you think so!
Hola se puede saber por que no hay traduccion al español el segundo idioma hablado?
I'm a newbie and I'm stuck at 5:34 of your video. How to show this code editor? (use command code . ?) and the name of this code editor?
Visual studio code
Very helpful 👍❤❤❤
When a wrote firebase deploy this is the message from my console:
Running command: npm --prefix "$RESOURCE_DIR" run lint
npm ERR! path E:\Cloud Functions\%RESOURCE_DIR%\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'E:\Cloud Functions\%RESOURCE_DIR%\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent