<?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: Daniel Medina</title>
    <description>The latest articles on DEV Community by Daniel Medina (@dnrm).</description>
    <link>https://dev.to/dnrm</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%2F403936%2F0ea2a919-f3a6-47fb-8fbb-9b5fc99f8927.jpg</url>
      <title>DEV Community: Daniel Medina</title>
      <link>https://dev.to/dnrm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dnrm"/>
    <language>en</language>
    <item>
      <title>My Experience with Next.js</title>
      <dc:creator>Daniel Medina</dc:creator>
      <pubDate>Mon, 02 Aug 2021 15:30:16 +0000</pubDate>
      <link>https://dev.to/dnrm/my-experience-with-next-js-13of</link>
      <guid>https://dev.to/dnrm/my-experience-with-next-js-13of</guid>
      <description>&lt;h1&gt;
  
  
  My Experience with Next.js
&lt;/h1&gt;

&lt;p&gt;By @&lt;a href="https://dev.to@dnrm"&gt;Daniel Medina&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Next.js?
&lt;/h2&gt;

&lt;p&gt;Next.js is a full-stack React framework that allows for both static site generation and server side rendering. It also allows for a new rendering strategy called &lt;a href="https://nextjs.org/docs/basic-features/data-fetching#incremental-static-regeneration" rel="noopener noreferrer"&gt;Incremental Static Regeneration&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It has a very big variety of features. Not only rendering strategies but also components such as the &lt;code&gt;Head&lt;/code&gt; or &lt;code&gt;Image&lt;/code&gt; components. You also get the power of &lt;strong&gt;API Routes&lt;/strong&gt; which are routes where you can use server side code to do a variety of tasks, for example connect to a database or handle authentication.&lt;/p&gt;

&lt;p&gt;Overall Next.js is by far the best Javascript framework if you want the biggest variety of features while maintaining a blazing fast site.&lt;/p&gt;

&lt;h2&gt;
  
  
  My experience
&lt;/h2&gt;

&lt;p&gt;I have been using Next.js for about 6 months now and I can confidently say that it does everything it promises to do, and it does it well. Do you want to have a server side rendered page for SEO? Next.js's Head component can handle that. Do you want to serve optimised images for better performance? Next.js's Image component can do that. Do you want to connect to a database and expose an endpoint without having to build and deploy a full backend? Next.js's API Routes will do that for you. Do you need to navigate through pages without refreshing? Next router can do that.&lt;/p&gt;

&lt;p&gt;Next really has all the features you will need and if you ever need anything not included, you can use any React package from NPM. Next has its own powers plus the community's. &lt;/p&gt;

&lt;h3&gt;
  
  
  Ease of Use
&lt;/h3&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.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1627875643568%2FqsGZPgEXE.png" 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.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1627875643568%2FqsGZPgEXE.png" alt="carbon.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was blown away at how it is extremely easy to get started with Next.js, just &lt;code&gt;yarn create next-app&lt;/code&gt; or &lt;code&gt;npx create-next-app&lt;/code&gt; and you now have a fully functional Next.js app ready to start creating your application, and if you want typescript then just add the &lt;code&gt;--typescript&lt;/code&gt; flag to the command. It's really that easy. You're ready to create your pages.&lt;/p&gt;

&lt;p&gt;Speaking about routing and creating pages, I love how every file in the pages directory becomes it's own page. No need for &lt;code&gt;react-router&lt;/code&gt; or any external package. Just create a new file with the .js or .tsx extension depending if you use typescript or not and boom! your page is now created.&lt;/p&gt;

&lt;h3&gt;
  
  
  Developer Experience
&lt;/h3&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.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1627876138996%2F2f6J16sId.png" 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.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1627876138996%2F2f6J16sId.png" alt="Captura de Pantalla 2021-08-01 a la(s) 22.48.48.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The developer experience with Next.js is actually really good. You can easily use Next if you know React. It is like a step up from a typical Create React App. Writing code with Next is a relatively good experience. There are no complex setup processes or other tedious tasks to be able to deploy your application. Next.js is also good at the developer experience because the file structure of your project is easy to understand. No need to search for files all over. Pages are in the &lt;code&gt;/pages&lt;/code&gt; directory and components in the &lt;code&gt;/components&lt;/code&gt;. It's that easy. Changed your mind and want to use typescript? Just create a &lt;code&gt;.tsx&lt;/code&gt; file and Next will automatically setup the typescript configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Next.js I've Seen
&lt;/h3&gt;

&lt;p&gt;Next.js facilitates a ton of aspects of developing a performant website. In my experience this has given me the ability to build my projects really quickly while maintaining a fast website. This is something many developers look for: the ability to develop quickly while not compromising the site's performance, and since Next accomplishes all of this, many developers and even enterprise companies such as Github or Netflix are switching to Next.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deployment
&lt;/h3&gt;

&lt;p&gt;Deploying a Next.js project is extremely easy. Just push your code to a Git repository and deploy with a hosting platform such as Vercel, a hosting platform made by the creators of Next specifically for Next.js. You can also run it in any Node.js server or even a Docker container. &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.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1627875565775%2F80zItry9qu.png" 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.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1627875565775%2F80zItry9qu.png" alt="Captura de Pantalla 2021-08-01 a la(s) 22.39.03.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My personal recommendation is Vercel because of how well it integrates with. It gives you analytics in the performance of your application, Incremental Static Regeneration, built in API Route support, and many more features. If you use Next.js you should probably deploy your appl to Vercel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Conclusion
&lt;/h3&gt;

&lt;p&gt;Overall, I really like Next.js. It has been my go-to framework for any new project. It will surely stay that way for a very long time. It just has everything I need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Huge amounts of libraries and plugins&lt;/li&gt;
&lt;li&gt;Server-side rendering and static site generation&lt;/li&gt;
&lt;li&gt;Ease of use&lt;/li&gt;
&lt;li&gt;React based&lt;/li&gt;
&lt;li&gt;Easy deployment process&lt;/li&gt;
&lt;li&gt;Large amount of built in features&lt;/li&gt;
&lt;li&gt;API Routes
Etc...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope you enjoyed reading about Next.js with me and I hope you try Next sometime soon. Thank you for reading my post! I appreciate it a lot :)&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>vercel</category>
    </item>
    <item>
      <title>My Experience With FreeCodeCamp</title>
      <dc:creator>Daniel Medina</dc:creator>
      <pubDate>Wed, 09 Jun 2021 16:02:12 +0000</pubDate>
      <link>https://dev.to/dnrm/my-experience-with-freecodecamp-14om</link>
      <guid>https://dev.to/dnrm/my-experience-with-freecodecamp-14om</guid>
      <description>&lt;p&gt;A year ago I joined freeCodeCamp and since I've now gotten 4 certifications, I thought I'd share my personal experience and thoughts about it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h4&gt;
  
  
  What is freeCodeCamp?
&lt;/h4&gt;

&lt;p&gt;FreeCodeCamp is a free online platform for learning all sorts of topics from Web Development to Machine Learning. Check it out &lt;a href="http://freecodecamp.org/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  My experience
&lt;/h2&gt;

&lt;p&gt;My first FreeCodeCamp course was te Responsive Web Design Certification. I found the learning method very interesting. I find this learning method really good because you actually get a hands-on experience with what you're learning. This way I learned a lot about core web technologies such as HTML, CSS, and Javascript. &lt;/p&gt;

&lt;p&gt;Something I like a lot about freeCodeCamp is that you have the flexibility to create your own schedule and practice whenever you want and are able to. There is no penalty for spending a little more time in something. &lt;/p&gt;

&lt;p&gt;I have completed the &lt;strong&gt;Responsive Web Design&lt;/strong&gt;, &lt;strong&gt;Javascript Algorithms and Data Structures&lt;/strong&gt;, &lt;strong&gt;Frontend Libraries&lt;/strong&gt;, and &lt;strong&gt;APIs and Microservices&lt;/strong&gt; Certifications. So I can say I've experienced quite a bit of the freeCodeCamp platform. For the most part I have nothing but positive feedback. I have recommended this several people who have asked me for help in starting their own career in webdev. One of them is now very experienced and has moved onto React. &lt;/p&gt;

&lt;h2&gt;
  
  
  Suggestions
&lt;/h2&gt;

&lt;p&gt;As much as there is good in this platform, there are some things that could be improved. &lt;/p&gt;

&lt;h3&gt;
  
  
  1. Improve Redux section.
&lt;/h3&gt;

&lt;p&gt;I struggled the most in the React-Redux section of the Front-end libraries certification because of explanations that i felt assumed previous knowledge of Redux. I felt they went a little too fast.&lt;/p&gt;

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

&lt;p&gt;Overall, I consider freeCodeCamp as one of the best platforms to start your web developer journey. It has clear, concise, and fast-paced explanations that are guaranteed to bump up your skills.&lt;/p&gt;

&lt;p&gt;Thanks for reading my article and make sure to keep in touch for more upcoming articles.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>freecodecamp</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Making A Really Simple Redis API with Node.js</title>
      <dc:creator>Daniel Medina</dc:creator>
      <pubDate>Mon, 16 Nov 2020 16:12:35 +0000</pubDate>
      <link>https://dev.to/dnrm/making-a-really-simple-redis-api-with-node-js-2ndj</link>
      <guid>https://dev.to/dnrm/making-a-really-simple-redis-api-with-node-js-2ndj</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Before I sart I would like to mention that this is my first post here at DEV so I'm excited about that. Thank you for reading my post. &lt;/p&gt;

&lt;p&gt;About a week ago I discovered Redis, a simple key-value database that claimed to be the fastest in the world. This claim comes from the fact that it stores the data in memory instead of disk. &lt;/p&gt;

&lt;p&gt;Being a fan of NodeJs and all JavaScript related stuff, the first thing I did was look for a NodeJs driver for Redis. Then I found  &lt;a href="https://redis.js.org"&gt;Node Redis&lt;/a&gt;  which was actually recommended in the official Redis website. I spent some time experimenting with it and eventually settled in making a simple API that could save and get items. &lt;/p&gt;

&lt;p&gt;Now I will show you how to make one of your own.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;You can find the finished code in my github at  &lt;a href="https://github.com/dnrm/redis-api"&gt;this link&lt;/a&gt; *&lt;/em&gt;&lt;/p&gt;




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

&lt;p&gt;Before getting into the code you should get your Redis database in the cloud. They have an option for a free database for unlimited time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://redislabs.com/try-free/"&gt;Sign up here&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;You should also have NodeJs installed with NPM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/en/download/"&gt;Download here&lt;/a&gt; &lt;/p&gt;




&lt;h2&gt;
  
  
  The Tutorial
&lt;/h2&gt;

&lt;p&gt;We'll start by installing the dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="nx"&gt;dotenv&lt;/span&gt; &lt;span class="nx"&gt;redis&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then setting up the .env file with the host, port, and password. You can find this in your Redis dashboard.&lt;/p&gt;

&lt;h4&gt;
  
  
  .env file
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REDIS_HOST=hostname
REDIS_PORT=port
REDIS_AUTH=password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that I created the index.js file and imported all the dependencies.&lt;/p&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&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;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&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;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;redis&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;redis&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;Next I created the Express app, the Redis client and set the port where the app would be listening.&lt;/p&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;



&lt;div class="highlight js-code-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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;REDIS_PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;REDIS_HOST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;5050&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;REDIS_AUTH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;err&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;Now we can start using Express to handle the API calls with the Redis client. What I did was set a &lt;strong&gt;GET&lt;/strong&gt; route for the root URL. This route will list all endpoints in the API.&lt;/p&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&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="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Looks like you've hit the root url&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;availableurls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/write/:key/:value&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/read/:key&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;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we will make another &lt;strong&gt;GET&lt;/strong&gt; route to read from the database. The URL will have a parameter of which key to read from the database.&lt;/p&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/read/:key&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;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reply&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&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="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;reply&lt;/span&gt;
        &lt;span class="p"&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;Now we just need to make our api be able to write to our database. Similar to our read function, write will take URL parameters. In this case both key and value.&lt;/p&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/write/:key/:value&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;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&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="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OK&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;Just for fun I will add a 404 route with a fun message. Feel free to sktip this step if you want. &lt;strong&gt;Note: the 404 route should go below all other routes.&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&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="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;what???&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;404&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;For our last step we just need to make our app listen in the specified port and we're done! &lt;/p&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`App successfully started on http://localhost:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We now have a working API that can both read and write to a Redis database in the cloud! Isn't that amazing? As mentioned before you can find the full code in my  &lt;a href="https://github.com/dnrm/redis-api"&gt;github repo&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Thank you very much for reading this post, it really means a lot for me. If you have any feedback, suggestions, or any comment really, feel free to let me know.&lt;/p&gt;

&lt;p&gt;Daniel&lt;/p&gt;

</description>
      <category>redis</category>
      <category>javascript</category>
      <category>node</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
