<?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: Akash Raju M</title>
    <description>The latest articles on DEV Community by Akash Raju M (@akashrajum7).</description>
    <link>https://dev.to/akashrajum7</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%2F201436%2F093a722a-87f9-4aff-a168-b094d07f4278.jpeg</url>
      <title>DEV Community: Akash Raju M</title>
      <link>https://dev.to/akashrajum7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akashrajum7"/>
    <language>en</language>
    <item>
      <title>Easily deploy express REST API as a serverless function for free using ZEIT</title>
      <dc:creator>Akash Raju M</dc:creator>
      <pubDate>Sat, 11 Apr 2020 15:33:19 +0000</pubDate>
      <link>https://dev.to/akashrajum7/easily-deploy-express-rest-api-as-a-serverless-function-for-free-using-zeit-1adj</link>
      <guid>https://dev.to/akashrajum7/easily-deploy-express-rest-api-as-a-serverless-function-for-free-using-zeit-1adj</guid>
      <description>&lt;p&gt;Guide to easily deploy your express API as a serverless function for free using ZEIT.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F8192%2F0%2ARNVW0j1sS2o56Ng6" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F8192%2F0%2ARNVW0j1sS2o56Ng6" alt="Photo by [Benjamin Voros](https://unsplash.com/@vorosbenisop?utm_source=medium&amp;amp;utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral) (Just a beautiful picture, not related to the content)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@vorosbenisop?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Benjamin Voros&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt; (Just a beautiful picture, not related to the content)&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;Serverless computing (or serverless for short), is an execution model where the cloud provider (AWS, Azure, or Google Cloud) is responsible for executing a piece of code by dynamically allocating the resources. And only charging for the number of resources used to run the code. The code is typically run inside stateless containers that can be triggered by a variety of events including HTTP requests, database events, queuing services, monitoring alerts, file uploads, scheduled events (Cron jobs), etc. The code that is sent to the cloud provider for execution is usually in the form of a function. Hence serverless is sometimes referred to as &lt;em&gt;“Functions as a Service”&lt;/em&gt; or &lt;em&gt;“FaaS”&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initialization
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;

&lt;p&gt;If you are on windows, I highly recommend you download and install git bash. It comes bundled with git and can be downloaded from here: &lt;a href="https://git-scm.com/downloads" rel="noopener noreferrer"&gt;https://git-scm.com/downloads&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Project setup
&lt;/h3&gt;

&lt;p&gt;Go to your projects folder and open terminal or git bash if on windows. We will now create a new folder and change into it. Copy and paste the command below to do it.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir express-serverless-example &amp;amp;&amp;amp; cd express-serverless-example
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now we will install all the required dependencies for the project, make sure nodejs(You can get it here: &lt;a href="https://nodejs.org/en/download/" rel="noopener noreferrer"&gt;https://nodejs.org/en/download/&lt;/a&gt;) is installed in your system. To make sure nodejs and npm are installed, you can run the below command to check the version of each.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node -v &amp;amp;&amp;amp; npm -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We will now initialize a new project, for that you run the command below. This will create a new package.json file with default options.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We will now install express.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We will now install now (CLI tool for ZEIT) as a global dependency.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -g now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now open the newly created folder in your favourite code editor, if you are using vscode(You can get it here: &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;https://code.visualstudio.com/&lt;/a&gt;), which I highly recommend, you can type the command below and it will open vscode.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;code .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Express code
&lt;/h2&gt;

&lt;p&gt;We will now create an ‘index.js’ file to create an express app(Filename &lt;strong&gt;MUST&lt;/strong&gt; be ‘index.js’ for it to work with ZEIT) and paste the following contents into it.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require("express");

const app = express();

const port = 3000;


// Body parser

app.use(express.urlencoded({ extended: false }));

// Home route

app.get("/", (req, res) =&amp;gt; {

res.send("Welcome to a basic express App");

});

// Users route

app.get("/users", (req, res) =&amp;gt; {

res.json([

{ name: "Akash", location: "India" },

{ name: "Abhishek", location: "India" },

]);

});

// Listen on port 5000

app.listen(port, () =&amp;gt; {

console.log(`Server is running on port 3000

Visit http://localhost:3000`);

});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That’s it, we are done with our basic express app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hosting
&lt;/h2&gt;

&lt;p&gt;If you haven’t already, create an account on &lt;a href="https://zeit.co/" rel="noopener noreferrer"&gt;https://zeit.co/&lt;/a&gt;, and type the below command in your terminal or git bash and follow instructions to log in.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;now login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Before we host our app in ZEIT, we must create a configuration file for it. To do that create a new file called ‘now.json’ and paste in below contents.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{

"version": 2,

"builds": [{ "src": "index.js", "use": "@now/node-server" }],

"routes": [

{

"src": "/",

"dest": "/index.js",

"methods": ["GET"]

},

{

"src": "/users",

"dest": "/index.js",

"methods": ["GET"]

}

]

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I’ll now explain each of the fields above, the &lt;a href="https://zeit.co/docs/configuration#project/version" rel="noopener noreferrer"&gt;version&lt;/a&gt; field will specify the ZEIT Now Platform version and &lt;a href="https://zeit.co/docs/configuration#project/builds" rel="noopener noreferrer"&gt;builds&lt;/a&gt; field will specify which build to use and which file to use as source and &lt;a href="https://zeit.co/docs/configuration#project/routes" rel="noopener noreferrer"&gt;routes&lt;/a&gt; field will specify all routes to use, this is the most important part so &lt;strong&gt;if you add a new route don't forget to include it here&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can find more info about configuration here &lt;a href="https://zeit.co/docs/configuration#introduction/configuration-reference" rel="noopener noreferrer"&gt;https://zeit.co/docs/configuration#introduction/configuration-reference&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we are all done, now you can run the command below to host your API on ZEIT.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The function should be successfully uploaded and you should get a link to access it.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>node</category>
      <category>free</category>
      <category>zeit</category>
    </item>
    <item>
      <title>Lessons learnt by failing in my first ever hackathon</title>
      <dc:creator>Akash Raju M</dc:creator>
      <pubDate>Sat, 11 Apr 2020 15:29:54 +0000</pubDate>
      <link>https://dev.to/akashrajum7/lessons-learnt-by-failing-in-my-first-ever-hackathon-4c0j</link>
      <guid>https://dev.to/akashrajum7/lessons-learnt-by-failing-in-my-first-ever-hackathon-4c0j</guid>
      <description>&lt;p&gt;Hope this article helps you avoid these mistakes that seem simple but can make a huge difference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n58sSBA4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/5984/0%2AdTDsW9r5j-d-B6g0" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n58sSBA4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/5984/0%2AdTDsW9r5j-d-B6g0" alt="Photo by [Estée Janssens](https://unsplash.com/@esteejanssens?utm_source=medium&amp;amp;utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@esteejanssens?utm_source=medium&amp;amp;utm_medium=referral"&gt;Estée Janssens&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It was a six-hour hackathon and we were a team of two people. We were competing with around fifteen other teams. We were all college students. It was a web development hackathon and we were provided with a problem statement at the beginning of the hackathon and we had to provide the solution by the end of the time limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The First Mistake&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The day before the hackathon, I discussed with my hackathon partner on what might the problem statement be and what to do if they decide to let us choose a problem statement. We also discussed what technologies and frameworks we will use. This is where I did my first mistake, I had recently started learning Vue.js and was very impressed by how easy it was to pick up and learn and how quickly you can build web apps with it. So I suggested that we would use vue.js for frontend and we could create an express backend API. Since I have been working with express for a while, I suggested that I will build the API and my partner would work on the frontend. The problem was he never worked with Vue.js before.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  Only choose a language, framework or library you are comfortable with to use in a hackathon.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since he was familiar with angular, I assumed it would be easy for him to pick up Vue.js and sent him an introduction video from youtube and he saw the video and understood the basics. The mistake here was obviously choosing a framework that he was not comfortable with. That was not too bad since, on the day of the hackathon, when we realised using Vue.js wouldn’t work, went back to using plain HTML, CSS with Jquery which he was good at.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Second Mistake
&lt;/h2&gt;

&lt;p&gt;It was the day of the hackathon, we came a little early to the place. Since we had a little bit of time with us, we decided to install all the required dependencies for the stack we were going to use.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  Always make sure beforehand that all the setup works properly in your system.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;There were only a few minutes before the hackathon started and for some reason, the Vue CLI failed to install on my partner's laptop, it was erroring out, the tension started building and we started panicking before we knew it, and the hackathon hasn’t even started.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Third Mistake
&lt;/h2&gt;

&lt;p&gt;The hackathon started and we were handed out our problem statement, the problem statement was that we had to build a comment’s module that would avoid creating new comment if it was found to be a duplicate or was similar. The frontend did not have a lot of the work to do at all, we quickly realised that using Vue.js wasn’t necessary and my partner started building the frontend using HTML, CSS and Jquery and I started with the backend API.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  The project structure doesn’t matter in a hackathon.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since it was my first hackathon, I didn’t realise how important time was in situations like these and I started creating different folders for different modules and all that stuff. In this process, I somehow missed writing code to connect to the database and the first four hours passed and we were still struggling with getting the comments to save to the database. I had worked with connecting database to express multiple times before, I would have realised if it showed any database connection error but unfortunately, it was failing without any error messages and I did not realise what was going wrong until it was too late.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fourth Mistake
&lt;/h2&gt;

&lt;p&gt;By this time, my partner realised that this was not going to work so he quickly started to write the backend in Java as he was good at it, all the while panicking. But it was too late so he had to rush it and we were left with a partially working module.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  Working with a time constraint changes a lot of things.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;You don’t realise how different things seem when you are under the pressure of running out of time until you are in that situation. We underestimated how things could go wrong and how small mistakes can cause big problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Make sure that you are comfortable with all the technologies that you choose to work within a hackathon. Make sure all the tools and setup required for your stack work properly on your system. If possible, try not to decide on the stack to use until you are aware of the problem statement. Don’t concentrate too much on the structure of your project and concentrate more on getting your project to work properly without confusion. If you are going to participate in a hackathon, practise beforehand with the constraints of the hackathon and most importantly, don’t panic.&lt;/p&gt;

</description>
      <category>hackathon</category>
      <category>failure</category>
      <category>lessons</category>
      <category>advice</category>
    </item>
  </channel>
</rss>
