<?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>Forem: Abraham E. Tavarez</title>
    <description>The latest articles on Forem by Abraham E. Tavarez (@abetavarez).</description>
    <link>https://forem.com/abetavarez</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%2F371246%2F0db23b81-3005-4b36-8431-95fa8e9c689c.png</url>
      <title>Forem: Abraham E. Tavarez</title>
      <link>https://forem.com/abetavarez</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/abetavarez"/>
    <language>en</language>
    <item>
      <title>How to Build a Chatbot with Next.js, TailwindCSS, and OpenAI Chat Completion API - Full Tutorial</title>
      <dc:creator>Abraham E. Tavarez</dc:creator>
      <pubDate>Mon, 22 Jul 2024 20:35:42 +0000</pubDate>
      <link>https://forem.com/abetavarez/how-to-build-a-chatbot-with-nextjs-tailwindcss-and-openai-chat-completion-api-full-tutorial-4ee1</link>
      <guid>https://forem.com/abetavarez/how-to-build-a-chatbot-with-nextjs-tailwindcss-and-openai-chat-completion-api-full-tutorial-4ee1</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Are you interested in creating a dynamic and responsive chatbot? In our latest YouTube tutorial, we walk you through building a chatbot using Next.js, TailwindCSS, and the OpenAI Chat Completion API. This step-by-step guide is perfect for developers of all levels looking to enhance their web development skills and create engaging user experiences.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technologies Used
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Next.js&lt;/strong&gt;: A powerful React framework that enables server-side rendering, static site generation, and easy API integration. Next.js is known for its performance and scalability, making it an excellent choice for modern web applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;TailwindCSS&lt;/strong&gt;: A utility-first CSS framework that allows for rapid styling and customization. TailwindCSS provides a responsive and cohesive design system without writing traditional CSS, streamlining the development process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OpenAI Chat Completion API&lt;/strong&gt;: This API leverages OpenAI's advanced language models to generate human-like responses, enabling the creation of intelligent and interactive chatbots. Integrating this API enhances the conversational capabilities of your chatbot.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;To give you a taste of what you'll learn in the tutorial, here’s a snippet of the code we’ll be working on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;chatCompletion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chatMessages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;[])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// Create chat with system prompt&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;system&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You're a helpful assistance&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;chatMessages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="c1"&gt;// API Request&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;completion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;openAI&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gpt-4o-mini&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="c1"&gt;// Completion result (new message)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;completion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;completion&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;
  
  
  Explanation:
&lt;/h2&gt;

&lt;p&gt;Function Definition and Parameter:&lt;/p&gt;

&lt;p&gt;The function &lt;strong&gt;chatCompletion&lt;/strong&gt; is an asynchronous function that takes an array of Message objects as its parameter. Each Message represents a chat message exchanged between the user and the assistant.&lt;br&gt;
Creating the Chat Array:&lt;/p&gt;

&lt;p&gt;The chat array is created by combining a system prompt ("You're a helpful assistant") with the &lt;strong&gt;chatMessages&lt;/strong&gt; provided as input. This system prompt helps guide the assistant's behavior in generating responses.&lt;br&gt;
API Request to OpenAI:&lt;/p&gt;

&lt;p&gt;The function makes a request to the &lt;strong&gt;OpenAI&lt;/strong&gt; API using the openAI.chat.completions.create method. This request includes the chat array and specifies the model &lt;strong&gt;gpt-4o-mini&lt;/strong&gt; to be used for generating the response.&lt;/p&gt;

&lt;p&gt;Handling the Completion Result:&lt;/p&gt;

&lt;p&gt;Once the API returns a response, the first choice of the generated completion (i.e., the new message from the assistant) is logged to the console.&lt;/p&gt;

&lt;p&gt;The function then returns the entire completion object.&lt;/p&gt;

&lt;p&gt;This code snippet demonstrates how to create a chat session with a system prompt, send it to the OpenAI API for generating a response, and handle the API's completion result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Watch the Tutorial?
&lt;/h2&gt;

&lt;p&gt;In our YouTube tutorial, we cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting up a Next.js project from scratch.&lt;/li&gt;
&lt;li&gt;Integrating TailwindCSS for a beautiful and responsive design.&lt;/li&gt;
&lt;li&gt;Connecting to the OpenAI Chat Completion API to enable intelligent conversations.&lt;/li&gt;
&lt;li&gt;Building a user-friendly chatbot interface.&lt;/li&gt;
&lt;li&gt;Deploying your chatbot to a live server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Watch the Full Tutorial
&lt;/h2&gt;

&lt;p&gt;Ready to dive in? Watch the full tutorial on our &lt;a href="https://youtu.be/gbZTEfo7BBo?si=Aak1smwav_mcqk0d" rel="noopener noreferrer"&gt;YouTube channel&lt;/a&gt; and start building your chatbot today. Don’t forget to like, share, and subscribe for more tutorials on web development and AI integration!&lt;/p&gt;

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

&lt;p&gt;By the end of this tutorial, you'll have a powerful chatbot that can engage users with intelligent conversations. This project is a great way to enhance your web development skills and explore the capabilities of modern web technologies. Happy coding!&lt;/p&gt;

&lt;h3&gt;
  
  
  Tags: #NextJS #TailwindCSS #OpenAI #Chatbot #WebDevelopment #CodingTutorial
&lt;/h3&gt;

</description>
      <category>typescript</category>
      <category>nextjs</category>
      <category>tailwindcss</category>
      <category>openai</category>
    </item>
    <item>
      <title>JavaScript Loops: For vs For of</title>
      <dc:creator>Abraham E. Tavarez</dc:creator>
      <pubDate>Fri, 17 Sep 2021 17:52:06 +0000</pubDate>
      <link>https://forem.com/abetavarez/javascript-loops-for-vs-for-of-33c3</link>
      <guid>https://forem.com/abetavarez/javascript-loops-for-vs-for-of-33c3</guid>
      <description>&lt;h1&gt;
  
  
  JavaScript Loops
&lt;/h1&gt;

&lt;p&gt;JavaScript, like many other programming languages, has many different kinds of loops. Some examples of these loops are &lt;em&gt;while loops&lt;/em&gt;, &lt;em&gt;for loops&lt;/em&gt;, &lt;em&gt;for of loops&lt;/em&gt;, and &lt;em&gt;for in loops&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Learning how and when to use the best kind of loop could be a bit overwhelming. Today we're going to talk about &lt;em&gt;for loops&lt;/em&gt; and &lt;em&gt;for of loops&lt;/em&gt;, which are two kinds that have a similar syntax.&lt;/p&gt;

&lt;p&gt;One of the most frequent use-cases of a loop, is to iterate or loop over an iterable object like a string, array or any array-like object such as (NodeList, Map, Set). We'll be working with an array. &lt;/p&gt;

&lt;h6&gt;
  
  
  Let's take a look at the &lt;em&gt;for loop&lt;/em&gt; syntax:
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (initialization; condition; final-expression) {
   statement
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;A &lt;em&gt;for loop&lt;/em&gt; consists of three optional expressions (initialization; condition; final-expression).&lt;/p&gt;
&lt;h6&gt;
  
  
  Let's look at some code
&lt;/h6&gt;

&lt;p&gt;In the example below, we have a nested array called &lt;em&gt;myArray&lt;/em&gt;, which contains two other arrays, which contain number values in them. (I'll reference these two other arrays as inner arrays to help you follow the code example).&lt;/p&gt;
&lt;h6&gt;
  
  
  Operation
&lt;/h6&gt;

&lt;p&gt;Let's say we need to get the total or the sum of the values inside of each of the inner arrays. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, we'll loop over &lt;em&gt;myArray&lt;/em&gt; to get access to the inner arrays. &lt;/li&gt;
&lt;li&gt;Then, we'll loop over each of the inner arrays and add all values inside of each of the inner arrays to a variable called &lt;em&gt;total&lt;/em&gt; and print the total.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Example with comments
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  Here is the same code without comments and extra spaces
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  What's happening here?
&lt;/h3&gt;

&lt;p&gt;Quick Aside: On line 4, I created a variable called &lt;code&gt;inner&lt;/code&gt; to hold the current value of each value inside &lt;code&gt;myArray&lt;/code&gt; (the two inner arrays). This is optional, it just makes your loop more readable. You can always reference the value like this: &lt;code&gt;myArray[i].length&lt;/code&gt; instead of &lt;code&gt;inner.length&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Notice when we use a &lt;em&gt;for loop&lt;/em&gt; we get access to the &lt;em&gt;index&lt;/em&gt; of the array, which is &lt;code&gt;i&lt;/code&gt; on the first loop and &lt;code&gt;n&lt;/code&gt; on the second loop.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Then we use &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;myArray&lt;/code&gt; to get each value of myArray -&amp;gt; &lt;code&gt;myArray[i]&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We also use &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;inner&lt;/code&gt; to get each value of the inner array -&amp;gt; &lt;code&gt;inner[n]&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally we add each value to the &lt;code&gt;total&lt;/code&gt; variable &lt;code&gt;total += inner[n]&lt;/code&gt; and print it to the console.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Behold: The 'For Of' Loop
&lt;/h1&gt;

&lt;h4&gt;
  
  
  First let's take a look at the syntax of a &lt;em&gt;for of loop&lt;/em&gt;:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (variable of iterable) {
  statement
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;The &lt;em&gt;for of loop&lt;/em&gt; will give you a more clean and readable syntax.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;
  
  
  Now let's see the same code using a &lt;em&gt;for of loop&lt;/em&gt;:
&lt;/h5&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  Much better
&lt;/h3&gt;

&lt;p&gt;The first thing we notice is a much shorter and readable syntax.&lt;/p&gt;

&lt;p&gt;On line 3, &lt;code&gt;for (let inner of myArray)&lt;/code&gt;; on each loop the variable &lt;em&gt;inner&lt;/em&gt; will be assigned each of the arrays in &lt;code&gt;myArray&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the first loop &lt;code&gt;inner&lt;/code&gt; will be assigned [11, 22, 33].&lt;/li&gt;
&lt;li&gt;On the second loop &lt;code&gt;inner&lt;/code&gt; will be assigned [55, 66, 77].&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On line 5 &lt;br&gt;
&lt;code&gt;for (let num of inner)&lt;/code&gt;; on each loop &lt;code&gt;num&lt;/code&gt; will be assigned the value of each number inside the current inner array:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For the first inner array &lt;code&gt;num&lt;/code&gt; will be assigned 11, then 22, then 33.&lt;/li&gt;
&lt;li&gt;For the second inner array &lt;code&gt;num&lt;/code&gt; will be assigned 55, then 66, then 77.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The syntax of a &lt;em&gt;for of loop&lt;/em&gt; is straight forward and concise. &lt;/p&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;
&lt;h5&gt;
  
  
  When should we use a &lt;em&gt;for loop&lt;/em&gt; or a &lt;em&gt;for of loop&lt;/em&gt;?
&lt;/h5&gt;

&lt;p&gt;A basic rule of thumb is, if you need access to the index of the values, then a &lt;em&gt;for loop&lt;/em&gt; will be a good choice. If you just need the values, you can use a &lt;em&gt;for of loop&lt;/em&gt; instead.&lt;/p&gt;

&lt;p&gt;You can still get the index inside of a &lt;em&gt;for of loop&lt;/em&gt; but it will use a different syntax. If you're curious, here is one last snippet:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Ok, that's it! I hope you liked this short article. &lt;br&gt;
Now go ahead and practice what we learned &lt;a href="https://replit.com/@abetavarez/For-of-Loops#index.js" rel="noopener noreferrer"&gt;replit&lt;/a&gt; and if you want to do some more reading on &lt;code&gt;Array.prototype.entries()&lt;/code&gt; here is a link to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading and don't forget to connect with me! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/efrenabrahametavarez/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Host a static-website on AWS S3</title>
      <dc:creator>Abraham E. Tavarez</dc:creator>
      <pubDate>Tue, 09 Mar 2021 13:14:21 +0000</pubDate>
      <link>https://forem.com/abetavarez/host-a-static-website-on-aws-s3-57n6</link>
      <guid>https://forem.com/abetavarez/host-a-static-website-on-aws-s3-57n6</guid>
      <description>&lt;p&gt;Are you looking for a free and easy way to host a static-website? Or maybe you're just looking to learn more about AWS S3? Either way, this article will help you!&lt;/p&gt;

&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;A &lt;strong&gt;static-website&lt;/strong&gt; is a website that doesn't change. All of its content is pre-built and static, just sitting somewhere as opposed to a dynamic website where its content is built at the time of the request and can change based on new data, for example, a weather website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS S3 (Simple Storage Service)&lt;/strong&gt; is a super easy storage solution that allows you to store and retrieve unlimited amounts of data from anywhere. You can store any kind of data on S3, from text files to pictures, data files, videos and more. AWS calls these files "objects," and the name of your object is called a key. &lt;/p&gt;

&lt;p&gt;Even though AWS S3 is simple to use, S3 also has advanced options for security, encryption and more. You can read more about &lt;a href="https://aws.amazon.com/s3/" rel="noopener noreferrer"&gt;AWS S3&lt;/a&gt; after you're done. &lt;/p&gt;

&lt;h2&gt;
  
  
  Let's get started
&lt;/h2&gt;

&lt;p&gt;If you don't have an AWS account, follow this link to create a &lt;a href="https://aws.amazon.com/" rel="noopener noreferrer"&gt;free AWS account&lt;/a&gt;. Otherwise, let's continue.&lt;/p&gt;

&lt;p&gt;1- Head over to our &lt;strong&gt;AWS Management Console&lt;/strong&gt;, then search for &lt;em&gt;S3&lt;/em&gt; and click on it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A3lrqqDj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/search_s3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A3lrqqDj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/search_s3.PNG" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Click on the big orange &lt;strong&gt;Create Bucket&lt;/strong&gt; button. &lt;br&gt;
You can think of a &lt;em&gt;Bucket&lt;/em&gt; as a folder for you to organize your data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VRjLG524--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/create_btn.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VRjLG524--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/create_btn.PNG" width="590" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- Now we need to give our Bucket a name. This name needs to be &lt;em&gt;globally unique&lt;/em&gt;. When you create a Bucket, AWS will create a URL that's unique to each Bucket in the world.&lt;/p&gt;

&lt;p&gt;I'll use my initials and the purpose of this Bucket as name:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mlIOJMPx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/bucket_name_region.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mlIOJMPx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/bucket_name_region.PNG" alt="create a bucket" width="658" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4- Uncheck &lt;strong&gt;Block all public access&lt;/strong&gt;. AWS by default will &lt;em&gt;Block all public access&lt;/em&gt;, so in order for the public to see your website, we need to make this particular Bucket public.&lt;br&gt;
Now, check the &lt;em&gt;acknowledge&lt;/em&gt; box so we can continue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wJ-BYlXS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/public_bucket.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wJ-BYlXS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/public_bucket.PNG" alt="creating public bucket" width="800" height="692"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5- Leave &lt;strong&gt;Bucket Versioning&lt;/strong&gt; and &lt;strong&gt;Default encryption&lt;/strong&gt; &lt;em&gt;Disabled&lt;/em&gt;. you can always &lt;em&gt;Enable&lt;/em&gt; them later if need it.&lt;/p&gt;

&lt;p&gt;6- Click &lt;strong&gt;Create bucket&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gr0B0JD1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/create_bucket_bottom.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gr0B0JD1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/create_bucket_bottom.PNG" alt="create bucket" width="800" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7- Nicely done! Now you can see that your new Bucket was created. Let's click on the Bucket and navigate to the &lt;strong&gt;Properties&lt;/strong&gt; tab:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cupw3oiO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/bucket_properties.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cupw3oiO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/bucket_properties.PNG" alt="properties tab" width="671" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;8- Scroll all the way to the bottom until you see &lt;strong&gt;Static website hosting&lt;/strong&gt; and click on &lt;strong&gt;Edit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;9- Click on &lt;strong&gt;Enable&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x4byFeNM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/enable_static.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x4byFeNM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/enable_static.PNG" alt="enable static" width="432" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;10- Go down to &lt;strong&gt;Index document&lt;/strong&gt; and type the name of the main or home page file of the website. If your file name is not already index.html, just write the name of the main page file.&lt;br&gt;
In my case its index.html:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--adS7CYGY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/main_file.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--adS7CYGY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/main_file.PNG" alt="main file" width="611" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;11- Scroll all the way down and click &lt;strong&gt;Save changes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;12- Well done! Now we're ready to upload our website files.&lt;br&gt;
If you need a template HTML page, you can download a simple one that I created for you on &lt;a href="https://github.com/AbeTavarez/static-website-template" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. (You can ignore the README.md file)&lt;br&gt;
Now that you have the files ready, click on the &lt;strong&gt;Objects&lt;/strong&gt; tab located on the same page, then click on the big orange &lt;strong&gt;Upload&lt;/strong&gt; Button: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6lh8yOWb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/upload_btn.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6lh8yOWb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/upload_btn.PNG" alt="upload button" width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;13- If you have a single file, you can upload your index.html file by clicking on &lt;strong&gt;Add files&lt;/strong&gt;. If you have multiple files, click on &lt;strong&gt;Add folder&lt;/strong&gt; instead.&lt;/p&gt;

&lt;p&gt;In my case, I have a Folder (HTML_Cloud_Resume) that contains an index.html file and another folder (CSS) that contains a main.css file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML_Cloud_Resume/index.html&lt;/li&gt;
&lt;li&gt;HTML_Cloud_Resume/CSS/main.css&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M8bQnwm3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/uploading_html_css.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M8bQnwm3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/uploading_html_css.PNG" alt="uploaded file" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now scroll down and click on &lt;strong&gt;Upload&lt;/strong&gt;, then click &lt;strong&gt;Close&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;14- Finally, you should see your folder listed:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rV9SCO0A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/folder_listed.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rV9SCO0A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/folder_listed.PNG" width="582" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on your folder, select all the &lt;strong&gt;Objects&lt;/strong&gt; in the folder, click on &lt;strong&gt;Actions&lt;/strong&gt;, scroll down and click on &lt;strong&gt;Make Public&lt;/strong&gt;, and then the orange &lt;strong&gt;Public&lt;/strong&gt; button again, and finally, click &lt;strong&gt;Close&lt;/strong&gt;. Now your &lt;em&gt;Objects&lt;/em&gt; are also public.&lt;br&gt;
&lt;em&gt;If you have any files inside other folders, make sure to make them public as well.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IH3UhHUx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/make_objects_publick.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IH3UhHUx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/make_objects_publick.PNG" alt="make objects public" width="618" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;15- To see your website, click on index.html and look for the &lt;strong&gt;Object URL&lt;/strong&gt; link:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CxRrS6e9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/object_url.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CxRrS6e9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/object_url.PNG" alt="object url" width="469" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations! If you followed all the steps you should be looking at your static-website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O1y2QVUB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/aws-static-site.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O1y2QVUB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://abe-assets-cloud.s3.us-east-2.amazonaws.com/aws-static-site.PNG" alt="site" width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can share this link with the world now. If you make any changes to the website files just upload again the files that you changed to your S3 &lt;strong&gt;Bucket&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Thanks for reading. Please share with your friends or leave me a clap or comment.  &lt;/p&gt;

&lt;p&gt;I'll see you on the next one!&lt;/p&gt;

&lt;p&gt;Contact me on &lt;a href="https://www.linkedin.com/in/efrenabrahametavarez/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>aws</category>
      <category>cloud</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JSON vs BSON</title>
      <dc:creator>Abraham E. Tavarez</dc:creator>
      <pubDate>Wed, 25 Nov 2020 14:48:07 +0000</pubDate>
      <link>https://forem.com/abetavarez/json-vs-bson-2f6b</link>
      <guid>https://forem.com/abetavarez/json-vs-bson-2f6b</guid>
      <description>&lt;h1&gt;
  
  
  What's the difference between JSON and BSON?
&lt;/h1&gt;

&lt;p&gt;To better understand the difference between JSON and BSON, first let's make sure we understand what JSON is.&lt;/p&gt;

&lt;h2&gt;
  
  
  JSON
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;JSON&lt;/strong&gt; is a lightweight data-format that is often used for structuring data primarily to send data between a server and an application over the internet. &lt;br&gt;
Many developers prefer building APIs using JSON format because of many reasons like for example readability.  &lt;/p&gt;

&lt;p&gt;Let's look at some key details about JSON:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON stands for &lt;strong&gt;JavaScript Object Notation&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;JSON is based on JavaScript in that they are conceptually similar to &lt;em&gt;objects&lt;/em&gt; in JavaScript.&lt;/li&gt;
&lt;li&gt;JSON is really easy for people to read and write, and easy for computers to parse and generate.&lt;/li&gt;
&lt;li&gt;JSON is a text format and is completely language independent.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Now let's look at an example representing a completely made up DEV post JSON object:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
    "Title": "JSON VS BSON",//String Type&lt;br&gt;
    "Author": "Abraham Tavarez",&lt;br&gt;
    "hasImage": true,// Boolean Type&lt;br&gt;
    "readTimeInMinutes": 1,// Number Type&lt;br&gt;
    "tags": ["beginners", "javascript"],// Array Type&lt;br&gt;
    "references": {&lt;br&gt;
        "json.org": "www.json.org",&lt;br&gt;
        "wikipedia": "www.wikipedia.org",&lt;br&gt;
        "bsonspec": "www.bsonspec.org/",&lt;br&gt;
        "mongoDB": "www.github.com/mongodb/mongo"&lt;br&gt;
    },// Embedded documents or objects&lt;br&gt;
    "previousArticles": null,// Null Type&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JSON has &lt;em&gt;six&lt;/em&gt; different data types as we can see in the JSON object example above. &lt;/p&gt;

&lt;p&gt;These types are: String, Boolean, Number, Array, Object and Null. &lt;br&gt;
Having only six types makes JSON super easy to understand and work with.&lt;/p&gt;

&lt;p&gt;Even though these types allow us to create an impressive amount of expressivity when formatting our data, &lt;em&gt;JSON's capabilities are still very limited&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;There are a few other types that are crucial for some applications like &lt;strong&gt;databases&lt;/strong&gt;. This is where &lt;strong&gt;BSON&lt;/strong&gt; comes to the rescue!&lt;/p&gt;

&lt;h2&gt;
  
  
  BSON
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;BSON&lt;/strong&gt; is a lightweight &lt;em&gt;binary-encoded&lt;/em&gt; serialization format capable of representing any JSON-like document.&lt;/p&gt;

&lt;p&gt;You can think of BSON as a superset of JSON. BSON supports all of the JSON types but also contains extensions or extra types that are not part of the JSON spec. BSON has well over a dozen of different types, we're going to see some of those types in an example below but here is a&lt;a href="https://docs.mongodb.com/manual/reference/bson-types/" rel="noopener noreferrer"&gt;  link &lt;/a&gt; to the full list. &lt;/p&gt;

&lt;p&gt;Let's come back to &lt;strong&gt;databases&lt;/strong&gt; for a second. For databases, working with dates and numbers is crucial. JSON has no Date type and only has a single Number type which is not enough to work with large numbers.  &lt;/p&gt;

&lt;p&gt;MongoDB database uses &lt;strong&gt;BSON&lt;/strong&gt; format to transfer MongoDB &lt;em&gt;documents&lt;/em&gt; between the client and the server.&lt;/p&gt;

&lt;p&gt;Documents are encoded to a &lt;em&gt;BSON string&lt;/em&gt; before being sent to the server and decoded by the driver before returning it to the client. &lt;/p&gt;

&lt;p&gt;Using &lt;em&gt;BSON&lt;/em&gt; to represent MongoDB's documents allows MongoDB to share data throughout MongoDB's ecosystem despite the language or driver you are writing your application in while maintaining &lt;em&gt;performance&lt;/em&gt;, &lt;em&gt;efficiency&lt;/em&gt;, and keeping data easy to &lt;em&gt;traverse&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Let's look at some key details about BSON:&lt;/p&gt;

&lt;p&gt;JSON to BSON: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia-temporary.preziusercontent.com%2Fframes-public%2F9%2F9%2Ff%2F7%2F8%2F907767d4df2b4f2b2e080521fb01200.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%2Fmedia-temporary.preziusercontent.com%2Fframes-public%2F9%2F9%2Ff%2F7%2F8%2F907767d4df2b4f2b2e080521fb01200.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;BSON stands for &lt;strong&gt;Binary JSON&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;BSON was created in 2009 by MongoDB.&lt;/li&gt;
&lt;li&gt;BSON documents are stored as a string of bytes.&lt;/li&gt;
&lt;li&gt;BSON has a variety of implementations depending on the language/driver you are using. &lt;strong&gt;For example JavaScript, Python, Java, C# and many more...&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;BSON is efficient, keeping the space used to a minimum.&lt;/li&gt;
&lt;li&gt;BSON is easy to traverse, which is useful for analyzing data.&lt;/li&gt;
&lt;li&gt;BSON is really fast in most programming languages.&lt;/li&gt;
&lt;li&gt;BSON uses C programing language for creating data types making the encoding and decoding process impressibly fast.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Finally, let's look at the same example but with new BSON types:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
    "_id": ObjectId(), // Object Type&lt;br&gt;
    "Article": "JSON VS BSON",&lt;br&gt;
    "Author": "Abraham Tavarez",&lt;br&gt;
    "hasImage": true,&lt;br&gt;
    "readTimeInMinutes": 1,&lt;br&gt;
    "tags": ["beginners", "javascript"],&lt;br&gt;
    "references": {&lt;br&gt;
        "json.org": "www.json.org",&lt;br&gt;
        "wikipedia": "www.wikipedia.org",&lt;br&gt;
        "bsonspec": "www.bsonspec.org/",&lt;br&gt;
        "mongoDB": "www.github.com/mongodb/mongo"&lt;br&gt;
    },&lt;br&gt;
    "previousArticles": null,&lt;br&gt;
    "postedOn": new Date(), // Date Type&lt;br&gt;
    "likes": NumberInt("343"),// NumberInt Type 4-byte&lt;br&gt;
    "shares": NumberLong("1254"),// NumberLong Type 8-byte&lt;br&gt;
    "totalLikes": function(){/your code here.../},// Code Type&lt;br&gt;
    "querytags": /beginner/i // Regular Expression Type   &lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  BSON Types:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Notice the ObjectId type at the top. ObjectId are the default identifier for documents in MongoDB.&lt;/li&gt;
&lt;li&gt;Date Type, notice how we can set the key "postedOn" to an instance of new Date(), pretty nifty.&lt;/li&gt;
&lt;li&gt;NumberInt for 4-byte integers and NumberLong for 8-byte integers.&lt;/li&gt;
&lt;li&gt;Code can also be store as a value in a BSON Object.&lt;/li&gt;
&lt;li&gt;Regular Expressions can also be store on BSON object to work with queries.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember, don't forget to read the &lt;a href="https://docs.mongodb.com/manual/reference/" rel="noopener noreferrer"&gt;docs&lt;/a&gt; for a full list of BSON types and to learn more about BSON and MongoDB.&lt;/p&gt;

&lt;p&gt;Thank you for taking your time to read this short article. I hope it was helpful for you. If you like it please let me know by leaving me a comment, like or share, also if you spot any errors please let me know as well.&lt;br&gt;
Happy hacking 👨🏻‍💻 🤘🏻.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/abrahametavarez/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt; | &lt;a href="https://www.facebook.com/abrahamtguzman3" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; | &lt;a href="https://github.com/AbeTavarez" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="span&amp;gt;Photo%20by%20&amp;lt;a%20href="&gt;Danny Nee&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/boxing?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt; Thanks for the awesome cover photo!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>mongodb</category>
      <category>javascript</category>
      <category>database</category>
    </item>
  </channel>
</rss>
