<?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: NarayaN Yaduvanshi</title>
    <description>The latest articles on DEV Community by NarayaN Yaduvanshi (@yadu).</description>
    <link>https://dev.to/yadu</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%2F687516%2Fe9e6fe51-9387-4157-92e5-09a9aea62ff7.jpeg</url>
      <title>DEV Community: NarayaN Yaduvanshi</title>
      <link>https://dev.to/yadu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yadu"/>
    <language>en</language>
    <item>
      <title>Fastify port is in use but in reality it is not</title>
      <dc:creator>NarayaN Yaduvanshi</dc:creator>
      <pubDate>Sun, 28 Nov 2021 07:46:37 +0000</pubDate>
      <link>https://dev.to/yadu/fastify-port-is-in-use-but-in-reality-it-is-not-22hi</link>
      <guid>https://dev.to/yadu/fastify-port-is-in-use-but-in-reality-it-is-not-22hi</guid>
      <description>&lt;h3&gt;
  
  
  Problem
&lt;/h3&gt;

&lt;p&gt;This happened to me when I was trying to run my fasify server on local port defined in .env file.&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;Fastify&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="nx"&gt;Port&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;already&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I noticed that port 3000 was available and no application was running on it. I even ran the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo pkill node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to kill all the instances of running node and free all the ports.&lt;br&gt;
This did not help&lt;/p&gt;
&lt;h3&gt;
  
  
  Solution
&lt;/h3&gt;

&lt;p&gt;Upon closer look I noticed that, all the values loaded from .env file are in type &lt;code&gt;String&lt;/code&gt; and thats what caused the issue. Fastify expect the port in &lt;code&gt;Number/Integer&lt;/code&gt; type. &lt;br&gt;
So simple solution to this problem is to conver or parse the string into number before passing it to fastify.&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;fastify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ParseInt&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;PORT&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>fastify</category>
      <category>server</category>
      <category>javascript</category>
    </item>
    <item>
      <title>The safest url shortener for the WEB</title>
      <dc:creator>NarayaN Yaduvanshi</dc:creator>
      <pubDate>Mon, 16 Aug 2021 15:27:23 +0000</pubDate>
      <link>https://dev.to/yadu/the-safest-url-shortener-for-the-web-4788</link>
      <guid>https://dev.to/yadu/the-safest-url-shortener-for-the-web-4788</guid>
      <description>&lt;p&gt;Almost all url shortener that I see today on world wide web comes in 2 simple part.&lt;br&gt;
&lt;code&gt;https://bit.ly/3jR0OWU&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Domain name&lt;/li&gt;
&lt;li&gt;combination of 6 alpha numerics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you click on it, it takes you to a long url.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;I as a user have no idea where these 6 alpha-numeric phrase mystery will take me.&lt;br&gt;
&lt;strong&gt;Let me take another eg:&lt;/strong&gt;&lt;br&gt;
Below I have 2 short URLs. One of them will take me to youtube website and other to a NSFW website. Can you tell me which one does what?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://bit.ly/2Uf76Xz"&gt;https://bit.ly/2Uf76Xz&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bit.ly/3jR0OWU"&gt;https://bit.ly/3jR0OWU&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(Don't be idiot like me and click these URLs without headphones on)&lt;/p&gt;

&lt;p&gt;To me, this is a problem, links are meant to inform you where they are taking you by their domains names. I like to not have surprises.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Below are 2 short URLs, Can you again take a look at them and tell me if you can figure out which short URL takes you to youtube and not the NSFW website.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://allurl.one/7bj0_p6idG/redtube.com"&gt;https://allurl.one/7bj0_p6idG/redtube.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://allurl.one/y-uSm2dP_8/youtube.com"&gt;https://allurl.one/y-uSm2dP_8/youtube.com&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I have added target domain as the third part of the url, so that web users can take an informed decision whether to click it or not.&lt;/p&gt;

&lt;p&gt;There it is, I believe this will make the web a little secure and links trustworthy. I means back to old times. Cheers&lt;/p&gt;

&lt;h2&gt;
  
  
  Also,
&lt;/h2&gt;

&lt;p&gt;If we go ahead with just the domain name and short code, we should give a choice to users whether they want to redirect to that site or not.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://allurl.one/y-uSm2dP_8"&gt;https://allurl.one/y-uSm2dP_8&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Clicking the above URL will take you to redirection page where it will inform you about the destination and give you a choice to abort or proceed. Just like this picture.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U0PXlfd_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/re2bl09fnvqxyc58dfh5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U0PXlfd_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/re2bl09fnvqxyc58dfh5.png" alt="choice to redirect"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>url</category>
      <category>safeweb</category>
      <category>links</category>
    </item>
  </channel>
</rss>
