<?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: Raphaël Badia</title>
    <description>The latest articles on DEV Community by Raphaël Badia (@raphaelbadia).</description>
    <link>https://dev.to/raphaelbadia</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%2F408860%2F836c20c1-cb62-4207-b6d7-33d535892f44.jpeg</url>
      <title>DEV Community: Raphaël Badia</title>
      <link>https://dev.to/raphaelbadia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raphaelbadia"/>
    <language>en</language>
    <item>
      <title>A stupid reason why cy.intercept() doesn't work when you reload Cypress tests</title>
      <dc:creator>Raphaël Badia</dc:creator>
      <pubDate>Wed, 28 Apr 2021 13:13:47 +0000</pubDate>
      <link>https://dev.to/raphaelbadia/a-stupid-reason-why-cy-intercept-doesn-t-work-when-you-reload-cypress-tests-ijd</link>
      <guid>https://dev.to/raphaelbadia/a-stupid-reason-why-cy-intercept-doesn-t-work-when-you-reload-cypress-tests-ijd</guid>
      <description>&lt;p&gt;When trying to intercept a search api of my website, a strange bug almost drove me crazy : the first time I ran the test, it worked, but then failed once I tried to reload the test !&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/NJZ308BKs1s"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;It turned out that there was a cache on the api side, so the browser is not doing an actual request once it's cached in the disk :&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dc286BNJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/69q95cttoc8izvuorand.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dc286BNJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/69q95cttoc8izvuorand.png" alt="CleanShot 2021-04-28 at 15.09.54@2x" width="740" height="652"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So from now on, I know that when I want to work with intercepted api responses that are cached, I must tick the "disable cache" checkbox.&lt;br&gt;
 &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nkwj6Eig--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jk6vy2l2f4w9xsq7ml42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nkwj6Eig--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jk6vy2l2f4w9xsq7ml42.png" alt="CleanShot 2021-04-28 at 15.13.07@2x" width="686" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Simulate slow responses with Cypress using cy.intercept()</title>
      <dc:creator>Raphaël Badia</dc:creator>
      <pubDate>Wed, 28 Apr 2021 11:51:32 +0000</pubDate>
      <link>https://dev.to/raphaelbadia/simulate-slow-responses-using-cypress-intercept-2oj5</link>
      <guid>https://dev.to/raphaelbadia/simulate-slow-responses-using-cypress-intercept-2oj5</guid>
      <description>&lt;p&gt;Today I was trying to debug a flaky test that regularly breaks our jenkins pipeline. The fault appeared to be due to a randomly slow api response.&lt;/p&gt;

&lt;p&gt;What I usually do is that I add a delay in my server to simulate the slow response and break the test, work my way to fix it and remove the delay in the server code.&lt;/p&gt;

&lt;p&gt;But today, I didn't have any control over the server. I had to find out another way to do that.&lt;/p&gt;

&lt;p&gt;Turns out it's quite easy with the Cypress &lt;code&gt;intercept&lt;/code&gt; command.&lt;br&gt;
You can pass a &lt;code&gt;req&lt;/code&gt; as an argument to intercept the request, and from there use &lt;code&gt;req.continue(response)&lt;/code&gt; to change the response.&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;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;intercept&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`_search`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;genera&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;span class="nx"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do nothing with the req, only call the response with a 10s delay.&lt;/span&gt;
    &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&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;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10000&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;send&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;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;practitioner&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;



</description>
      <category>todayilearned</category>
    </item>
    <item>
      <title>How to change electron forge's renderer port</title>
      <dc:creator>Raphaël Badia</dc:creator>
      <pubDate>Sun, 14 Jun 2020 17:51:23 +0000</pubDate>
      <link>https://dev.to/raphaelbadia/how-to-change-electron-forge-s-renderer-port-4c5m</link>
      <guid>https://dev.to/raphaelbadia/how-to-change-electron-forge-s-renderer-port-4c5m</guid>
      <description>&lt;p&gt;I just started using electron-forge and I stumbled across a problem : when trying to change the renderer's port (that runs by default on port 3000), my changes to the webpack file were ignored...&lt;/p&gt;

&lt;p&gt;I found out on their &lt;a href="https://github.com/electron-userland/electron-forge/blob/master/packages/plugin/webpack/src/WebpackPlugin.ts"&gt;github&lt;/a&gt; that they override the webpack config in their custom webpack (&lt;code&gt;@electron-forge/plugin-webpack&lt;/code&gt;) package. But they still gave us two options (&lt;code&gt;port&lt;/code&gt; and &lt;code&gt;loggerPort&lt;/code&gt;) to achieve our needs and you can write them in the package.json like so :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"config"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"forge"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
             &lt;/span&gt;&lt;span class="nl"&gt;"plugins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                 &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                      &lt;/span&gt;&lt;span class="s2"&gt;"@electron-forge/plugin-webpack"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                           &lt;/span&gt;&lt;span class="nl"&gt;"port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="w"&gt;
                           &lt;/span&gt;&lt;span class="nl"&gt;"loggerPort"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;9001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="w"&gt;
                      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
                  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
             &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A bit too nested and undocumented if you want my opinion.&lt;/p&gt;

</description>
      <category>electronforge</category>
      <category>electron</category>
      <category>webpack</category>
    </item>
    <item>
      <title>How I read react websites unminified source code through source maps</title>
      <dc:creator>Raphaël Badia</dc:creator>
      <pubDate>Sun, 14 Jun 2020 17:49:34 +0000</pubDate>
      <link>https://dev.to/raphaelbadia/how-i-read-react-websites-unminified-source-code-through-source-maps-3j9o</link>
      <guid>https://dev.to/raphaelbadia/how-i-read-react-websites-unminified-source-code-through-source-maps-3j9o</guid>
      <description>&lt;p&gt;Have you ever heard about source maps ?&lt;/p&gt;

&lt;p&gt;They are the files that link minified js files to the original source file, allowing the browser to show you where the error is in the debugger.&lt;br&gt;
It’s very useful for development purpose but can also be used in production to track bugs down.&lt;br&gt;
And as &lt;a href="https://css-tricks.com/should-i-use-source-maps-in-production/" rel="noopener noreferrer"&gt;this article&lt;/a&gt; says, it can also expose the source code of some websites, enabling other developers to learn by reading your codebase !&lt;/p&gt;

&lt;p&gt;So, can we find some source map file available on google ? Google dorks makes it easy to find out. Let’s type &lt;code&gt;ext:map&lt;/code&gt;. A lot of false positives… &lt;code&gt;ext:map intext:webpack intext:react&lt;/code&gt; is way better but it returns a lot of results from git hosts such as GitHub and gitlab. &lt;/p&gt;

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

ext:map intext:webpack intext:react -site:github.com -intitle:GitLab -inurl:(git|blob|repo|browse)


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

&lt;/div&gt;

&lt;p&gt;Better. That leaves us with a lot of sourcemaps to explore ! Let’s download a random on, I chose this one : &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%2Fv1590251115867%2FoBKpQAZjS.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%2Fv1590251115867%2FoBKpQAZjS.png" alt="CleanShot 2020-05-23 at 18.24.54@2x.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;To download a sourcemap file, you only need to click on it and save it as a &lt;code&gt;.map&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To extract the source code from the source map, we are going to use a package called &lt;code&gt;source-map-unpack&lt;/code&gt;. Unfortunately, some dependencies are outdated so we need to either install it with and old nodes version. You can do that with &lt;a href="https://github.com/nvm-sh/nvm" rel="noopener noreferrer"&gt;nvm&lt;/a&gt; : &lt;code&gt;nvm use v10.20.1&lt;/code&gt;. If you don't have nvm, you can clone the repository, remove the ascii-progress dependency just &lt;a href="https://github.com/pavloko/source-map-unpack/pull/1/files" rel="noopener noreferrer"&gt;like this&lt;/a&gt; and &lt;code&gt;npm install&lt;/code&gt;. Then, running &lt;code&gt;npx source-map-unpack ancestry ~/Downloads/landing-bundle.js-485a22ea.map&lt;/code&gt; (or &lt;code&gt;npm start ancestry ./path/to/source/file.map&lt;/code&gt; if you cloned the repository) will create a folder &lt;code&gt;ancestry&lt;/code&gt; containing the source code !&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%2Fv1590251511234%2FuTOv-Jjhs.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%2Fv1590251511234%2FuTOv-Jjhs.png" alt="CleanShot 2020-05-23 at 18.31.15@2x.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A preview of the folder created by source-map-unpack&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can see actions, reducers, components... It's an app using redux ! &lt;br&gt;
This doesn't seems like a full app, and the sourcemap filename (&lt;code&gt;landing-bundle.js-485a22ea.map&lt;/code&gt;) made me think it was a single page. After some digging, I found I was reading the source code for &lt;a href="https://www.ancestry.com/learn/facts" rel="noopener noreferrer"&gt;https://www.ancestry.com/learn/facts&lt;/a&gt; :&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%2Fv1590252604577%2FIS6MN7wEL.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1590252604577%2FIS6MN7wEL.gif" alt="CleanShot 2020-05-23 at 18.49.20.gif"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A demonstration of the /learn/facts page behavior next to the extracted source code&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  When things get serious
&lt;/h1&gt;

&lt;p&gt;Later, I stumbled on an interesting bundle name: &lt;code&gt;app.js.map&lt;/code&gt;. It was 4 mb large, which I thought could be a more complete app. And gosh, what I got was &lt;strong&gt;way more&lt;/strong&gt; interesting than the previous source map : I was looking at the source of the whole client dashboard of an energy company !&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%2Fv1590266716381%2FtW0MLeX2D.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%2Fv1590266716381%2FtW0MLeX2D.png" alt="CleanShot 2020-05-23 at 18.03.53@2x.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I learned some interesting things and saw good practices by skimming through their code,  but also some weird things (they were abusively using refs and document.querySelector). And they had &lt;strong&gt;two&lt;/strong&gt; &lt;code&gt;useState()&lt;/code&gt; in total. The rest was class component.&lt;/p&gt;

&lt;p&gt;Learning from others code is really interesting and you should definitely go take a look. There are a lot of US government open data sourcemap out there.&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%2Fv1590268818039%2FVP1IGdP44.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%2Fv1590268818039%2FVP1IGdP44.png" alt="CleanShot 2020-05-23 at 23.18.10@2x.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;As for me, I'm going to try to forget the raw SQL queries I've seen on data.nasa.gov...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading !&lt;/p&gt;

</description>
      <category>sourcemap</category>
      <category>googledorks</category>
      <category>react</category>
      <category>security</category>
    </item>
    <item>
      <title>How to avoid and debug most of timezone problems in production</title>
      <dc:creator>Raphaël Badia</dc:creator>
      <pubDate>Sun, 14 Jun 2020 17:48:07 +0000</pubDate>
      <link>https://dev.to/raphaelbadia/how-to-avoid-and-debug-most-of-timezone-problems-in-production-2h1l</link>
      <guid>https://dev.to/raphaelbadia/how-to-avoid-and-debug-most-of-timezone-problems-in-production-2h1l</guid>
      <description>&lt;p&gt;Have you ever been struggling to reproduce a weird bug happening only on production? &lt;br&gt;
Some offset between what you have in local (that obviously works perfectly) and what your clients see on this evil, inaccessible server?&lt;/p&gt;

&lt;p&gt;If you're using anything other than Windows Server, there are chances your server is using the UTC timezone, which is not - unless you live in England - the same timezone than your computer.&lt;/p&gt;

&lt;p&gt;The simplest solution to reproduce what's happening on your server is to set your timezone to UTC. And there is a way to run node in UTC without changing your computer timezone!&lt;/p&gt;

&lt;p&gt;To use UTC as your node timezone, you can simply set it in the env before running node, like so :&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="nv"&gt;TZ&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;utc node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also works with other timezones, for instance this would set the timezone to Amsterdam's one:&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="nv"&gt;TZ&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Europe/Amsterdam'&lt;/span&gt; node server/index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I recommand setting it in your package.json to always develop to stay as close as possible to production's conditions. In my package.json it looks like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TZ=utc nodemon --max_old_space_size=8192 server/index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you're not using UTC on production, you should definitely read &lt;a href="http://yellerapp.com/posts/2015-01-12-the-worst-server-setup-you-can-make.html"&gt;The worst Server Setup Mistake You Can Make&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Good luck debugging your timezone issues !&lt;/p&gt;

</description>
      <category>node</category>
      <category>nextjs</category>
      <category>nestjs</category>
      <category>timezone</category>
    </item>
    <item>
      <title>Fixing class-validator issues in a new Nest js project</title>
      <dc:creator>Raphaël Badia</dc:creator>
      <pubDate>Sun, 14 Jun 2020 17:46:24 +0000</pubDate>
      <link>https://dev.to/raphaelbadia/fixing-class-validator-issues-in-a-new-nest-js-project-2547</link>
      <guid>https://dev.to/raphaelbadia/fixing-class-validator-issues-in-a-new-nest-js-project-2547</guid>
      <description>&lt;p&gt;&lt;em&gt;This weekend, I played a bit with this express-based node.js framework called&lt;/em&gt; &lt;strong&gt;Nest&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's remind first what is a DTO :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A DTO (Data Transfer Object) is an object that defines how the data will be sent over the network. &lt;/p&gt;

&lt;p&gt;It defines the shape of data for a specific case, such as creating an user:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;CreateuserDto {&lt;br&gt;
    name: 'john',&lt;br&gt;
    password: 'isthissecureENOUGH??123'&lt;br&gt;
}&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Or updating the status of a shipping:
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;UpdateShippingStatusDto {&lt;br&gt;
    status: 'ON_HOLD'&lt;br&gt;
}&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, I love the concept of DTO and I was trying to validate it using &lt;code&gt;ValidationPipe&lt;/code&gt;, just like &lt;a href="https://docs.nestjs.com/techniques/validation#auto-validation" rel="noopener noreferrer"&gt;the doc&lt;/a&gt; says. It quickly went wrong:&lt;/p&gt;

&lt;h2&gt;
  
  
  The "class-validator" package is missing. Please, make sure to install this library ($ npm install class-validator) to take advantage of ValidationPipe.
&lt;/h2&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%2Fv1586094310885%2FWYdLgXJ0t.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%2Fv1586094310885%2FWYdLgXJ0t.png" alt="CleanShot 2020-04-05 at 15.44.34.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oh. I thought it would work out of the box since ValidationPipe comes from &lt;code&gt;@nest/common&lt;/code&gt;, but nevermind, the fix is easy :&lt;/p&gt;

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

npm install class-validator


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

&lt;/div&gt;

&lt;p&gt;No more errors in my console ! I carried on and sent a POST request on my endpoint...&lt;/p&gt;

&lt;h2&gt;
  
  
  Nest: No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies.
&lt;/h2&gt;

&lt;p&gt;This one made me crazy. Should I install class-validator as a peer dependency ? Is it a problem in the yarn.lock or in package.json ?&lt;/p&gt;

&lt;p&gt;Not at all ! It turned out that my DTO had &lt;em&gt;&lt;strong&gt;zero&lt;/strong&gt;&lt;/em&gt; validation rules !&lt;/p&gt;

&lt;p&gt;It's that simple : if you get a &lt;code&gt;No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies.&lt;/code&gt; when using &lt;code&gt;ValidationPipe&lt;/code&gt;, triple-check that you have at least one validation rule.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

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

import { IsNotEmpty } from "class-validator";

export class CreateUserDto {
    @IsNotEmpty()
    firstName: string;
    lastName: string;
}


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/a/55491966" rel="noopener noreferrer"&gt;This stackoverflow comment&lt;/a&gt; saved the day. Thanks !&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>classvalidator</category>
      <category>validationpipe</category>
      <category>nest</category>
    </item>
    <item>
      <title>How to create an electron-forge project with React, Typescript and HMR</title>
      <dc:creator>Raphaël Badia</dc:creator>
      <pubDate>Sun, 14 Jun 2020 17:44:09 +0000</pubDate>
      <link>https://dev.to/raphaelbadia/how-to-create-an-electron-forge-project-with-react-typescript-and-hmr-1gi3</link>
      <guid>https://dev.to/raphaelbadia/how-to-create-an-electron-forge-project-with-react-typescript-and-hmr-1gi3</guid>
      <description>&lt;h2&gt;
  
  
  introduction
&lt;/h2&gt;

&lt;p&gt;This post has been transferred to my &lt;a href="https://raphael.badia.cc/"&gt;blog&lt;/a&gt;. You can read the &lt;a href="https://raphael.badia.cc/posts/create-electron-forge-project-react-typescript-hmr"&gt;latest version&lt;/a&gt; here: &lt;br&gt;
  &lt;a href="https://raphael.badia.cc/posts/create-electron-forge-project-react-typescript-hmr"&gt;How to create an electron-forge project with React, Typescript and HMR&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;As a react developer, I've always been used to magic CLIs that scaffold projects with everything included, such as Next.js or create-react-app. I don't think I ever setup react from scratch, but there is no electron-forge template for that, so I had to dig in...&lt;/p&gt;
&lt;h2&gt;
  
  
  What we want
&lt;/h2&gt;

&lt;p&gt;A buildable electron project that includes :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;react&lt;/li&gt;
&lt;li&gt;typescript&lt;/li&gt;
&lt;li&gt;hot module reloading on the react part&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Getting started with the &lt;em&gt;webpack-typescript&lt;/em&gt; template
&lt;/h2&gt;

&lt;p&gt;electron-forge provides us a convenient &lt;code&gt;webpack-typescript&lt;/code&gt; that generates a boilerplate configured with typescript and webpack support (who would have guessed ?).&lt;br&gt;
Create the project using the following command :&lt;br&gt;
&lt;code&gt;yarn create electron-app my-new-app --template=typescript-webpack&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once the project has been created, enter it and run the project to ensure it works:&lt;br&gt;
&lt;code&gt;cd my-new-app&lt;/code&gt;&lt;br&gt;
&lt;code&gt;yarn start&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R7pvoxq---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/6g6cenvfn11hvzvd8z69.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R7pvoxq---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/6g6cenvfn11hvzvd8z69.png" alt='The default app should open and display "Hello World"' width="800" height="603"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The default app should open and display "Hello World"&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Adding react
&lt;/h2&gt;

&lt;p&gt;Now that our app opens properly, we need to add react dependencies.&lt;br&gt;
In the terminal, run: &lt;code&gt;yarn add react react-dom @types/react @types/react-dom&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That done, replace the content of the body by the div that will contain the react app in &lt;code&gt;src/index.html&lt;/code&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;@@ -6,7 +6,6 @@&lt;/span&gt;

   &amp;lt;/head&amp;gt;
   &amp;lt;body&amp;gt;
&lt;span class="gd"&gt;-    &amp;lt;h1&amp;gt;💖 Hello World!&amp;lt;/h1&amp;gt;
-    &amp;lt;p&amp;gt;Welcome to your Electron application.&amp;lt;/p&amp;gt;
&lt;/span&gt;&lt;span class="gi"&gt;+    &amp;lt;div id="root"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/span&gt;   &amp;lt;/body&amp;gt;
 &amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file in &lt;code&gt;src&lt;/code&gt; called &lt;code&gt;App.tsx&lt;/code&gt; and paste the following code into it :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&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;App&lt;/span&gt; &lt;span class="o"&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;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hi from react !&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make sure typescript understands jsx, add &lt;code&gt;"jsx": "react"&lt;/code&gt; in your &lt;code&gt;tsconfig.json&lt;/code&gt; file like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;@@ -12,7 +12,8 @@&lt;/span&gt;
     "resolveJsonModule": true,
     "paths": {
       "*": ["node_modules/*"]
&lt;span class="gd"&gt;-    }
&lt;/span&gt;&lt;span class="gi"&gt;+    },
+    "jsx": "react"
&lt;/span&gt;   },
   "include": [
     "src/**/*"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to update the renderer to bind react to the div we created earlier.&lt;br&gt;
First, rename it from &lt;code&gt;src/renderer.ts&lt;/code&gt; to &lt;code&gt;src/renderer.tsx&lt;/code&gt; then replace the content by the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;,&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&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;Now update the js entryPoint in &lt;code&gt;package.json&lt;/code&gt; with the correct name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;@@ -52,7 +52,7 @@&lt;/span&gt;
               "entryPoints": [
                 {
                   "html": "./src/index.html",
&lt;span class="gd"&gt;-                  "js": "./src/renderer.ts",
&lt;/span&gt;&lt;span class="gi"&gt;+                  "js": "./src/renderer.tsx",
&lt;/span&gt;                   "name": "main_window"
                 }
               ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now run &lt;code&gt;yarn start&lt;/code&gt;. The application should open and the react app should appear !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bFw-0d3s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ibojieikibrsz5w20ooh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bFw-0d3s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ibojieikibrsz5w20ooh.png" alt="The application successfully running react" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, if you try to change some code in the App.tsx, the changes won't appear on your App. We need to manually install a module to hot reload changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding hot-reload
&lt;/h2&gt;

&lt;p&gt;We're almost there ! Run &lt;code&gt;yarn add react-hot-loader&lt;/code&gt;, then head over &lt;code&gt;srx/App.tsx&lt;/code&gt; and add the following lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;@@ -1,5 +1,6 @@&lt;/span&gt;
&lt;span class="gi"&gt;+import { hot } from 'react-hot-loader';
&lt;/span&gt; import * as React from 'react';

 const App = () =&amp;gt; &amp;lt;div&amp;gt;Hi from react!&amp;lt;/div&amp;gt;;

-export default App;
&lt;span class="err"&gt;\&lt;/span&gt; No newline at end of file
&lt;span class="gi"&gt;+export default hot(module)(App);
&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt; No newline at end of file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we need to configure babel to use the &lt;code&gt;react-hot-loader&lt;/code&gt; package that will enable hot reloading by creating a &lt;code&gt;.babelrc&lt;/code&gt; file at the root of the repository and putting only one line into it :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#.babelrc
{ "plugins": ["react-hot-loader/babel"] }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, run &lt;code&gt;yarn start&lt;/code&gt;, change the message, hit save and it should work !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aC5mapjP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1592155896926/p-4gk6I1l.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aC5mapjP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1592155896926/p-4gk6I1l.gif" alt="CleanShot 2020-06-14 at 19.30.39.gif" width="633" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope it helps !&lt;/p&gt;

</description>
      <category>react</category>
      <category>electron</category>
      <category>typescript</category>
      <category>webpack</category>
    </item>
  </channel>
</rss>
