<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shine Santhosh</title>
    <description>The latest articles on DEV Community by Shine Santhosh (@shinesanthosh).</description>
    <link>https://dev.to/shinesanthosh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F211334%2Fee49e75b-c99d-42b9-a543-6bbf1765db12.jpg</url>
      <title>DEV Community: Shine Santhosh</title>
      <link>https://dev.to/shinesanthosh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shinesanthosh"/>
    <language>en</language>
    <item>
      <title>Getting Started with Google Firebase (Part-2)</title>
      <dc:creator>Shine Santhosh</dc:creator>
      <pubDate>Fri, 24 Apr 2020 16:07:51 +0000</pubDate>
      <link>https://dev.to/shinesanthosh/getting-started-with-google-firebase-part-2-3ecn</link>
      <guid>https://dev.to/shinesanthosh/getting-started-with-google-firebase-part-2-3ecn</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Let's continue to explore firebase&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Make sure to read &lt;a href="https://dev.to/shinesanthosh2/getting-started-with-google-firebase-part-1-10gn"&gt;Part-1&lt;/a&gt; before you begin&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;During the time I wrote this post Cloud Functions was free to use (with some restrictions). But later Google updated the policy making it accessible only if you are on the blaze plan(A pay-as-you-go plan) &lt;/p&gt;


&lt;/blockquote&gt;

&lt;p&gt;In the previous session, we created an account and started a new firebase project. And today we'll make our hands dirty. This part requires some coding. We'll be using &lt;em&gt;nodeJS&lt;/em&gt;, so make sure you know a little bit of that and ExpressJs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;a href="http://https://nodejs.org/en/download/"&gt;nodeJS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;An IDE. You can use your favorite one. But we recommend using &lt;a href="http://https://code.visualstudio.com/"&gt;VSCode&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the previous part of this series, we created a new firebase project. And today we'll explore &lt;code&gt;CLOUD FUNCTIONS&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cloud Functions??
&lt;/h2&gt;

&lt;p&gt;Cloud Functions for Firebase is a serverless framework that lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your JavaScript or TypeScript code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the environment
&lt;/h2&gt;

&lt;p&gt;To start coding a cloud function. We must set up an environment with emulators and stuff so that we can test our code on our machine itself before deploying it to the GCP.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To install the Firebase CLI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you install NodeJS you can install firebase CLI using npm by using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;firebase-tools &lt;span class="nt"&gt;-g&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will install firebase CLI globally on your system.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initiating the project on your system&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Login to your Google account using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt; firebase login
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After you do that you'll get a link. Open that link in your browser and log in with your account.&lt;/p&gt;




&lt;p&gt;Now to initiate the project use command prompt or terminal to navigate into the directory where you want to set as the workspace. Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;firebase init functions
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When you are asked to select a project option. Select the &lt;code&gt;use existing project option&lt;/code&gt; and select your project from the list. And for the languages option use JavaScript as we'll be using that. We may not need the ESLint. But you can go with it if you need it. Make sure to install all the dependencies from npm&lt;/p&gt;

&lt;p&gt;And there you go the initialization is complete.&lt;/p&gt;

&lt;h2&gt;
  
  
  First Piece of code
&lt;/h2&gt;

&lt;p&gt;Take a look at your workspace. The directory should have some new files by now along with a new folder called functions.&lt;/p&gt;

&lt;p&gt;And in that folder, you'll see an &lt;code&gt;index.js&lt;/code&gt; file. That's the file where you should write the code. Open that. You'll see some commented lines. You've to uncomment some lines to make it as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;functions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;firebase-functions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;helloWorld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;functions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onRequest&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello from Firebase!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you've ever used expressJs, You'll feel at home now because firebase uses express.&lt;br&gt;
And this will be the first piece of code we gonna deploy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;functions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;firebase-functions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This code imports firebase functions into your code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;helloWorld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;functions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onRequest&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World from firebase&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is our HTTP request triggered cloud function with the name &lt;code&gt;helloWorld&lt;/code&gt;.&lt;br&gt;
Once it gets an HTTP trigger, the function is initiated and it sends a response.&lt;/p&gt;


&lt;h2&gt;
  
  
  Testing locally with the emulator
&lt;/h2&gt;

&lt;p&gt;So now to test our function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;firebase serve
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This should start a server and you'll get a link on the localhost. Open that link and you'll be able to see your code in action.&lt;/p&gt;

&lt;p&gt;We made the stupidest app ever. But yeah it's the Hello world app. You can make changes as you like if you know express.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying it
&lt;/h2&gt;

&lt;p&gt;We've seen our code running smoothly without any issues(As there's nothing to cause an issue because it's such a silly code). It is running on our local machine. Now to put it into the cloud, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;firebase deploy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You'll get the link of your deployed code under function URL. Open it:&lt;/p&gt;

&lt;p&gt;Woohoo. That stupid thing is on the cloud. Now head over to your firebase console and open the functions from the navigation panel on left(or whatever you call it).&lt;/p&gt;

&lt;p&gt;You can see the statistics of your function there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Winding-up
&lt;/h2&gt;

&lt;p&gt;So We have our first code on firebase. Now it's useless and dumb and does nothing at all. We'll try to create an API with the help of firestore in the next part of this series.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Thank you. We'll continue to explore more in the coming sessions. Keep exploring.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>firebase</category>
      <category>tutorial</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Getting Started with Google Firebase (Part-1)</title>
      <dc:creator>Shine Santhosh</dc:creator>
      <pubDate>Fri, 24 Apr 2020 15:48:45 +0000</pubDate>
      <link>https://dev.to/shinesanthosh/getting-started-with-google-firebase-part-1-10gn</link>
      <guid>https://dev.to/shinesanthosh/getting-started-with-google-firebase-part-1-10gn</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;During the time I wrote this post Cloud Functions was free to use (with some restrictions). But later Google updated the policy making it accessible only if you are on the blaze plan(A pay-as-you-go plan) &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Firebase is a mobile and web application development platform that helps developers to focus on their front-end rather than solving the puzzles and issues in the back-end. If you’re among those who wanted to dive deep into cloud-computing and got discouraged as you weren’t willing to rip your pockets off, there’s happy news for you. You can get started with Firebase for free (Not even credit card details are needed).&lt;/p&gt;




&lt;p&gt;You can find more details about cloud computing in our &lt;a href="http://dartigo.netlify.com/modtech-cloud"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can create and deploy your APIs on the cloud for free (The basic account has some restrictions though).&lt;/p&gt;

&lt;p&gt;Let's have a look at what Firebase offers:&lt;/p&gt;




&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A decent knowledge of JavaScript&lt;/li&gt;
&lt;li&gt;Prior experince with ExpressJS will be awesome
Don't worry if you don't know any of those. Have look at our other posts:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://dartigo.netlify.com/basic-coding"&gt;Basic Coding&lt;/a&gt; or &lt;a href="http://dartigo.netlify.com/learn-online"&gt;Online-Learning&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Create a Firebase account
&lt;/h2&gt;

&lt;p&gt;As mentioned before, it’s free and simple. All you need to do is to authenticate with your existing Google account. &lt;br&gt;
Head over to &lt;a href="http://firebase.google.com"&gt;firebase.google.com&lt;/a&gt; and click get started and authenticate with your existing Google account.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a new project
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uCXeh068--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dartigo.netlify.app/static/8f1c7c7497a4b76bb940da0faae9b491/6d23f/project.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uCXeh068--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dartigo.netlify.app/static/8f1c7c7497a4b76bb940da0faae9b491/6d23f/project.png" alt="Project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Firebase console is where you do most of the work.&lt;/p&gt;

&lt;p&gt;Go to &lt;a href="http://console.firebase.google.com"&gt;console.firebase.google.com&lt;/a&gt; and explore your console.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can create a new project, or explore some demo project.&lt;/li&gt;
&lt;li&gt;Click on create project, You’ll be prompted to give a name for your project&lt;/li&gt;
&lt;li&gt;Just below the name, you’ll see an id. &lt;strong&gt;This is important&lt;/strong&gt;. You can edit the id as you like or keep it as it is, but you can’t change it after you create a project.&lt;/li&gt;
&lt;li&gt;Accept the terms and continue.&lt;/li&gt;
&lt;li&gt;It will ask if you need Google analytics in your project. (It’s up to you as we won’t cover that).&lt;/li&gt;
&lt;li&gt;Create your project.&lt;/li&gt;
&lt;li&gt;Done!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Back to the console
&lt;/h2&gt;

&lt;p&gt;Go to the Firebase console again (You’ll be redirected after creating the project).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on your project and you’ll see details about your project, the current plan, etc.&lt;/li&gt;
&lt;li&gt;On the left navigator, you’ll see the option called Develop. This window shows what we can do with firebase. Let’s explore some of them:

&lt;ul&gt;
&lt;li&gt;Authentication: Options for integrating Google authentication into your app&lt;/li&gt;
&lt;li&gt;Database: Handling of Databases.&lt;/li&gt;
&lt;li&gt;Hosting: To host your website on GCP&lt;/li&gt;
&lt;li&gt;Functions: Cloud functions to create and deploy your APIs&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There’s a lot more to explore. Visit the official &lt;a href="https://firebase.google.com/docs"&gt;Firebase Docs&lt;/a&gt; or &lt;a href="https://www.youtube.com/user/Firebase"&gt;Firebase Youtube Channel&lt;/a&gt; for tutorials and Help.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As this post is getting large, We’ll continue exploring firebase in the next Post. Keep exploring...&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>firebase</category>
      <category>introduction</category>
      <category>cloud</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
