<?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: Rafael Sant'Ana</title>
    <description>The latest articles on Forem by Rafael Sant'Ana (@tsuyusk).</description>
    <link>https://forem.com/tsuyusk</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%2F411763%2F9620a93d-5e7d-4a1e-b902-3cef8f1c1671.png</url>
      <title>Forem: Rafael Sant'Ana</title>
      <link>https://forem.com/tsuyusk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tsuyusk"/>
    <language>en</language>
    <item>
      <title>This might be increasing your bundle size!</title>
      <dc:creator>Rafael Sant'Ana</dc:creator>
      <pubDate>Tue, 03 Jan 2023 22:05:40 +0000</pubDate>
      <link>https://forem.com/tsuyusk/this-might-be-slowing-down-your-code-187m</link>
      <guid>https://forem.com/tsuyusk/this-might-be-slowing-down-your-code-187m</guid>
      <description>&lt;p&gt;Hi there!&lt;/p&gt;

&lt;p&gt;This is known by a bunch of people, but maybe you didn't know it, just like I didn't (':&lt;/p&gt;

&lt;p&gt;Some time ago, I was on LinkedIn and I saw an interesting project. Inside the code, there was a code snippet similar to this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3mcqcud0y05n06jvjkv1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3mcqcud0y05n06jvjkv1.png" alt="Wildcard Icon Example" width="800" height="506"&gt;&lt;/a&gt;&lt;br&gt;
I thought it was clever, it seemed clearly better than tons of lines just for importing icons, then I started using it in most of my codes.&lt;/p&gt;

&lt;p&gt;Recently, though, a work colleague told me not to, because in fact NodeJS builds with all the icons, even the ones that were not used, and therefore, increasing the project size and reducing the performace.&lt;/p&gt;

&lt;p&gt;Instead, in fact, it is more advantageous to import one by one, similar to this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftxkndtl7yf2ucumfgy0k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftxkndtl7yf2ucumfgy0k.png" alt="Not Wildcard Example" width="674" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post wouldn't be so useful if it didn't contain a way of knowing whether importing wildcard or one-by-one is more effective to your code.&lt;br&gt;
And for this, I recommend a Vscode extension called '&lt;a href="https://citw.medium.com/keep-your-bundle-size-under-control-with-import-cost-vscode-extension-5d476b3c5a76" rel="noopener noreferrer"&gt;Import Cost&lt;/a&gt;'&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftybax6sbp9trcedsdv3i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftybax6sbp9trcedsdv3i.png" alt="Import Cost 1" width="578" height="30"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9i98vd9m3pygocitv0s6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9i98vd9m3pygocitv0s6.png" alt="Import Cost 2" width="487" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Obs: Wildcard imports are still a very valid option, but mostly if you'll use all or most of the imported content (:&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>github</category>
    </item>
    <item>
      <title>How to improve imports in your code</title>
      <dc:creator>Rafael Sant'Ana</dc:creator>
      <pubDate>Tue, 13 Jul 2021 14:15:13 +0000</pubDate>
      <link>https://forem.com/tsuyusk/how-to-improve-imports-in-your-code-a2k</link>
      <guid>https://forem.com/tsuyusk/how-to-improve-imports-in-your-code-a2k</guid>
      <description>&lt;p&gt;Hello, there!&lt;/p&gt;

&lt;p&gt;After a while without new posts, I decided to come back with a really useful tip to simplify your code and reduce repetition.&lt;/p&gt;

&lt;p&gt;Have you ever saw a code like this ?&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2di1gwpgz9ct89nfq54v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2di1gwpgz9ct89nfq54v.png" alt="many_imports" width="800" height="375"&gt;&lt;/a&gt;&lt;br&gt;
Wouldn't It be great if we could simply shorten it to this ?&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3dsayxdhwlol63xf7zg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3dsayxdhwlol63xf7zg.png" alt="simplified_imports" width="772" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, It's possible!&lt;/p&gt;

&lt;p&gt;In order to do it, we will simply create a file named 'index.(js/ts)' inside components' folder, and add the following code in it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frc64qti3sn571grwt8kp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frc64qti3sn571grwt8kp.png" alt="exports_index_ts" width="800" height="768"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And now you can import components easier from other files without needing to repeat their names.&lt;/p&gt;



&lt;p&gt;If you think that it is still not worth it, because in index.(js/ts) the components are still being imported, there is another solution:&lt;/p&gt;

&lt;p&gt;Instead of default exporting components&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simply export them without default keyword&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nc"&gt;Input &lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in index.(js/ts) do this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxu81dxxum68zxrbddji9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxu81dxxum68zxrbddji9.png" alt="second_way_to_simplify" width="756" height="516"&gt;&lt;/a&gt; &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>5 Extremely useful javascript methods that You might not know</title>
      <dc:creator>Rafael Sant'Ana</dc:creator>
      <pubDate>Sun, 27 Sep 2020 03:04:01 +0000</pubDate>
      <link>https://forem.com/tsuyusk/5-extremely-useful-javascript-methods-that-you-might-not-know-14l6</link>
      <guid>https://forem.com/tsuyusk/5-extremely-useful-javascript-methods-that-you-might-not-know-14l6</guid>
      <description>&lt;p&gt;Hi ! Recently I've been studying more about some Javascript methods and I found some really interesting ones, I hope it can help you to code faster and easier ! Soo, Let's begin:&lt;/p&gt;

&lt;h2&gt;
  
  
  PadStart()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsor78b2bw1wtdgfgw33p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsor78b2bw1wtdgfgw33p.png" alt="Padstart demo" width="772" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By looking to the picture You probably understood but if You didn't, let me explain it better:&lt;br&gt;
padStart is a string method, it means it can only be used with strings. Having set that, it works at the following way: the string on the second parameter will be added at the beggining of the string if its length is lower than the number in first parameter.&lt;br&gt;
In other words, in the first parameter You tell the max length and in the second one, what the method will fill the string with.&lt;/p&gt;

&lt;h2&gt;
  
  
  padEnd()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl5lk7n6dmciiqgdj1knf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl5lk7n6dmciiqgdj1knf.png" alt="PadEnd example" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It works just like padStart, but the difference is that instead of adding a text at the beggining of the string, it adds a text at the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  reduce()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1v3e0cvqmpp6l1zlzyez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1v3e0cvqmpp6l1zlzyez.png" alt="Reduce example" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reduce is an Array manipulation method, it needs a function as the first parameter, this function has two parameters, commonly named 'accumulator' and 'currentValue', and returning a value inside this function will make 'accumulator' have this value. The second parameter defines the start value of accumulator.&lt;/p&gt;

&lt;h2&gt;
  
  
  forEach()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkfzjic9lhqhnewx0zpzv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkfzjic9lhqhnewx0zpzv.png" alt="ForEach Example" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;forEach will execute a function for each value in the array. In this example, we sum 3 numbers to each element in the array.&lt;/p&gt;

&lt;h2&gt;
  
  
  toFixed()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffjc2ei596pxz0j0ed0wr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffjc2ei596pxz0j0ed0wr.png" alt="toFixed example" width="638" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This function removes the decimal part of a number, but it can also limit how many numbers there are in the decimal part of a number, as in the second example.&lt;/p&gt;

&lt;h2&gt;
  
  
  toLocaleString()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhbnv7c7im9yd1ijz92ng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhbnv7c7im9yd1ijz92ng.png" alt="toLocaleString example" width="800" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This function is a little more complex, but it basically converts a number to a formatted string. In the first parameter it takes a locale (For example, en-US). The second parameter is opcional but it takes format options, you can check them out &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Soo, that's it! I hope it helped you guys!&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Basics about NestJS</title>
      <dc:creator>Rafael Sant'Ana</dc:creator>
      <pubDate>Fri, 25 Sep 2020 16:23:51 +0000</pubDate>
      <link>https://forem.com/tsuyusk/basics-about-nestjs-4glh</link>
      <guid>https://forem.com/tsuyusk/basics-about-nestjs-4glh</guid>
      <description>&lt;p&gt;Hi again ! Today I'm going to write a little bit about NestJS -&amp;gt; A NodeJS framework made in order to make backend development in  NodeJS way faster, I'm currently loving it ~even more than ExpressJs~ !&lt;/p&gt;

&lt;p&gt;So, before beggining, I recommend you to use NestJs Cli and knowing a little bit about &lt;a href="https://www.typescriptlang.org/docs/handbook/decorators.html"&gt;decorators&lt;/a&gt;. For installing it, You have to run this command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @nestjs/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once It is done, You can already use their CLI, you can access it typing 'nest' in your terminal, if you wanna know more about their cli, &lt;a href="https://docs.nestjs.com/cli/overview"&gt;Check their website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Okay so, let's start a project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="c"&gt;# nest new name_of_project is the command we use for starting a new project&lt;/span&gt;
  nest new my-first-nestjs-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay so, when it installs all dependencies, You will have a project like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftbd8cudjvuihg9aoijt0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftbd8cudjvuihg9aoijt0.jpg" alt="Boilerplate folder structure" width="221" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then you might think... what is 'module', 'service' and 'controller' ? &lt;br&gt;
Well, If you have already tried NestJS, You probably already know, but I'll try to explain:&lt;/p&gt;
&lt;h2&gt;
  
  
  app.service.ts
&lt;/h2&gt;

&lt;p&gt;Starting by the services, let's go to 'app.service.ts' file, you will see this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzm1x2t29wp5w0nafimy4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzm1x2t29wp5w0nafimy4.jpg" alt="app.service.ts file" width="532" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@Injectable()&lt;/code&gt; basically says that, according to dependency injection principles, that class may be injected in another variable&lt;/p&gt;

&lt;p&gt;Now, focus on 'getHello' function, it is a really simple function that returns ' Hello ', simple, right ?&lt;/p&gt;
&lt;h2&gt;
  
  
  app.controller.ts
&lt;/h2&gt;

&lt;p&gt;Now, If you go to 'app.controller.ts' file, There will be:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq7t2e1l9khn9jsa8rtzw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq7t2e1l9khn9jsa8rtzw.jpg" alt="app.controller.ts file" width="553" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You probably already understood what it does, but if You didnt:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@Controller()&lt;/code&gt; indicates that the following class is a Controller&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@Get()&lt;/code&gt; indicates that the following function will be runned when a HTTP request with GET method happens, if there aren't parameters inside Get decorator, it will be the same than '/'&lt;/p&gt;

&lt;p&gt;&lt;code&gt;constructor(private readonly appService: AppService) {}&lt;/code&gt; indicates  that &lt;code&gt;this.appService&lt;/code&gt; is an instance of AppService class.&lt;/p&gt;

&lt;p&gt;So basically when You access http:localhost:3000, it will run 'getHello' function, which will return ' Hello ' and then ' Hello ' will be written in your screen.&lt;/p&gt;

&lt;p&gt;You might be wondering " What about app.module.ts ? How does my controller know that he needs to inject AppService ? ", and I will explain it now:&lt;/p&gt;
&lt;h2&gt;
  
  
  App.module.ts
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foziu6taseuy84vinz0tz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foziu6taseuy84vinz0tz.jpg" alt="App.module.ts file" width="553" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Controllers&lt;/code&gt; indicates what are the (controllers)[&lt;a href="https://docs.nestjs.com/controllers"&gt;https://docs.nestjs.com/controllers&lt;/a&gt;] of that module, and providers indicates what are the &lt;a href="https://docs.nestjs.com/providers"&gt;providers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Because of "providers", "AppController" file knows that "AppService" exists and that "appService" is an instance of it&lt;/p&gt;
&lt;h2&gt;
  
  
  main.ts
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6tdws13j2tutv4zbdpj2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6tdws13j2tutv4zbdpj2.jpg" alt="main.ts file" width="553" height="181"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This file is the entry file, It basically says that the server controller and providers are in "AppModule" and that the server will run on port 3000.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to start a NestJS project
&lt;/h2&gt;

&lt;p&gt;There are two main ways to run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  yarn start
  &lt;span class="c"&gt;# And&lt;/span&gt;
  yarn start:dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;yarn start would be like running node on a server.js express file, and yarn start:dev would be like running nodemon on a server.js express file&lt;/p&gt;

&lt;p&gt;Soo that's it guys, I hope it helped You to understand a little bit of NestJS boilerplate and when I learn more about how it works I intend to make another post teaching how to make a simple CRUD with it, also, If you got interested, I invite you to check out &lt;a href="https://docs.nestjs.com/"&gt;Their documentation&lt;/a&gt;, The documentation is extremely well constructed and I'm sure it will help you !&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>backend</category>
      <category>node</category>
    </item>
    <item>
      <title>Making an animated header with Framer Motion</title>
      <dc:creator>Rafael Sant'Ana</dc:creator>
      <pubDate>Mon, 21 Sep 2020 16:36:13 +0000</pubDate>
      <link>https://forem.com/tsuyusk/making-an-animated-header-with-framer-motion-3p7e</link>
      <guid>https://forem.com/tsuyusk/making-an-animated-header-with-framer-motion-3p7e</guid>
      <description>&lt;p&gt;Hi! Recently I've watched a video about basics of Framer Motion - A ReactJS library made in order to help to make animations - and  I wanted to share a little bit of what I've learnt.&lt;/p&gt;

&lt;p&gt;We will create a simple header component, and it will work just like the below one (Pay attention to the scrollbar and the header):&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl4p3d1kc8fi34hnvxaq4.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl4p3d1kc8fi34hnvxaq4.gif" alt="Working demonstration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to start, You need to create a react app and install 'framer-motion' library&lt;/p&gt;

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

  &lt;span class="c"&gt;# Creating a react app&lt;/span&gt;
  npx create-react-app framer-header / yarn create react-app framer-header

  &lt;span class="c"&gt;# Installing with NPM and with Yarn:&lt;/span&gt;
  npm &lt;span class="nb"&gt;install &lt;/span&gt;framer-motion / yarn add framer-motion


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

&lt;/div&gt;

&lt;p&gt;So, even though I'm still studying it, I've learnt a bit about animations throughout the page scroll, doing this would usually be kinda difficult but happily We have Framer motion + React hooks !&lt;/p&gt;

&lt;p&gt;In order to make a simple animation that makes the header disapear, we can start by creating a basic Header component in 'src/components/Header.js':&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fr5gomxyrh1ft0pv21ba2.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fr5gomxyrh1ft0pv21ba2.png" alt="Header component"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Okay, but... what are 'motion', 'useViewportScroll' and 'useTransform'?&lt;/p&gt;

&lt;p&gt;Motion is kind of a component that You use for styling, just like 'animated' from React Spring.&lt;/p&gt;

&lt;p&gt;useViewportScroll is a hook that returns how many % of the page has been scrolled in decimal numbers, in this case, we want to know how many % of the Y axis has been scrolled&lt;/p&gt;

&lt;p&gt;useTransform is the hook that allows us to make some of animations, in this case, it is what will make our header leave the screen. It works at the following way: When the value of the first parameter is in the range of the second parameter, it will return a number depending on the third parameter&lt;/p&gt;

&lt;p&gt;Confusing? Maybe, but let me show you two examples:&lt;/p&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;scaleY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&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="s1"&gt;0%&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="s1"&gt;100%&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;scaleY would be ' 50% ' because 2 is in the exact middle between 1 and 4, but if the first parameter were ' 4 ', scaleY would be 100%&lt;/p&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;scrollYProgress&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useViewportScroll&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;headerY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;,&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="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.3&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="s1"&gt;0%&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="s1"&gt;0%&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="s1"&gt;-100%&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;When 0% of the page has been scrolled, headerY will be ' 0% ',&lt;br&gt;
When 20% of the page has been scrolled, headerY will be ' 0% ',&lt;br&gt;
When 25% of the page has been scrolled, headerY will be ' -50% ',&lt;br&gt;
When 30% of the page has been scrolled, headerY will be '-100% ',&lt;/p&gt;

&lt;p&gt;Now, so that we can see this component and the scrollbar, lets make some changes in 'App.js', it will be just like this one:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F68zzyjcoygqg9yarvpj7.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F68zzyjcoygqg9yarvpj7.png" alt="App.js example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can check the code out in the following link: &lt;a href="https://codesandbox.io/s/purple-lake-k33ly" rel="noopener noreferrer"&gt;https://codesandbox.io/s/purple-lake-k33ly&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it guys, see you!&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>css</category>
      <category>animation</category>
    </item>
  </channel>
</rss>
