<?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: Médéric Burlet</title>
    <description>The latest articles on DEV Community by Médéric Burlet (@crimsonmed).</description>
    <link>https://dev.to/crimsonmed</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%2F187045%2F096e2d89-d8ea-4637-a577-d2fab7bbb1fd.jpg</url>
      <title>DEV Community: Médéric Burlet</title>
      <link>https://dev.to/crimsonmed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/crimsonmed"/>
    <language>en</language>
    <item>
      <title>Typescript - T3 / Chakra UI Boilerplate</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Thu, 08 Jun 2023 14:14:34 +0000</pubDate>
      <link>https://dev.to/crimsonmed/typescript-t3-chakra-ui-boilerplate-28mj</link>
      <guid>https://dev.to/crimsonmed/typescript-t3-chakra-ui-boilerplate-28mj</guid>
      <description>&lt;p&gt;Recently i've been working a lot with T3 stack. &lt;/p&gt;

&lt;p&gt;I have loved using it but i've found tailwind to be too descriptive and thus wanted a version ready to use with chakra-ui.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/crimson-med"&gt;
        crimson-med
      &lt;/a&gt; / &lt;a href="https://github.com/crimson-med/t3-chakra-template"&gt;
        t3-chakra-template
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      T3 template incorporating Chakra UI
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Create T3 App&lt;/h1&gt;
&lt;p&gt;This is a &lt;a href="https://create.t3.gg/" rel="nofollow"&gt;T3 Stack&lt;/a&gt; project but that incorporates Chakra-UI and user login and password with prisma.&lt;/p&gt;
&lt;h2&gt;
Installation&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Run the installation with: &lt;code&gt;yarn&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Make a copy of &lt;code&gt;.env.example&lt;/code&gt; to &lt;code&gt;.env&lt;/code&gt; and fill in: &lt;code&gt;NEXTAUTH_SECRET&lt;/code&gt; and &lt;code&gt;NEXTAUTH_URL&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Run the seeding to create users and posts: &lt;code&gt;yarn migrate/seed&lt;/code&gt; you can find the passwords in: &lt;code&gt;prisma/seed.ts&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If you want to configure Discord Login you can add the API info in: &lt;code&gt;.env&lt;/code&gt; and uncomment the discord config in &lt;code&gt;src/server/auth.ts&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
Boilerplate Examples&lt;/h2&gt;
&lt;p&gt;This boilerplate shares a few different aspects of T3 while making a few changes.&lt;/p&gt;
&lt;h3&gt;
Menu&lt;/h3&gt;
&lt;p&gt;You can find in &lt;code&gt;src/components/menu.tsx&lt;/code&gt; a basic menu with items and sub items as well as Signin and Signup.&lt;/p&gt;
&lt;p&gt;You can also specify if items are to be shown when authed.&lt;/p&gt;
&lt;h3&gt;
Signin &amp;amp; Signup&lt;/h3&gt;
&lt;p&gt;This currently has nextauth which can integrate many login system: &lt;a href="https://next-auth.js.org" rel="nofollow"&gt;NextAuth.js&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This template was also configured to allow signin / signup…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/crimson-med/t3-chakra-template"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;For those unfamiliar with T3 it uses Next, NextAuth, Prisma, tRPC and in this case Chakra-UI.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nextjs.org"&gt;Next.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://next-auth.js.org"&gt;NextAuth.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://prisma.io"&gt;Prisma&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chakra-ui.com/"&gt;Chakra UI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://trpc.io"&gt;tRPC&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For now it supports simple signup / signin with username and password. &lt;/p&gt;

&lt;p&gt;A simple data seeding script creates 3 users with some random posts. &lt;/p&gt;

&lt;p&gt;You can see your own posts once logged in.&lt;/p&gt;

&lt;p&gt;All default passwords are in the seed file.&lt;/p&gt;




&lt;p&gt;Burlet Mederic&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/crimson_med"&gt;https://twitter.com/crimson_med&lt;/a&gt;&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Create Random team names for projects</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Tue, 22 Mar 2022 08:26:55 +0000</pubDate>
      <link>https://dev.to/pixiumdigital/create-random-team-names-for-projects-3nf9</link>
      <guid>https://dev.to/pixiumdigital/create-random-team-names-for-projects-3nf9</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Here at &lt;strong&gt;Pixium Digital&lt;/strong&gt; we often need to create sets of random usernames or team names.&lt;/p&gt;

&lt;p&gt;This is either due to bench-marking with a need to simulate individuals groups or users.&lt;/p&gt;

&lt;p&gt;Or for a need to &lt;strong&gt;anonymize leader-boards&lt;/strong&gt; in various applications. This can be due to the fact that some applications have big firms as client that they want to keep anonymous hence we generate a random team or group name that can be displayed publicly without risking information leakage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/xT4uQBmMGEoGWSCCVG/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xT4uQBmMGEoGWSCCVG/giphy.gif" alt="leaderboard" width="320" height="158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this we have decided to build a small library that we can re-use to help us generate this content easily.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basics
&lt;/h2&gt;

&lt;p&gt;We first started to create a list of various information we would need. This includes adjectives, nouns, gamertags, colors, extended colors.&lt;/p&gt;

&lt;p&gt;You find the more detailed list here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pixiumdigital/random-namer/tree/master/src/data"&gt;https://github.com/pixiumdigital/random-namer/tree/master/src/data&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;We then wanted to create the possibility to add an ID at the end of the random generated content (discord like) so we could have a result like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;myC00lUsername#3948&lt;/li&gt;
&lt;li&gt;thundering-memory#8682&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this we used a little trick of &lt;code&gt;Math.random()&lt;/code&gt;&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="cm"&gt;/**
 * Generates a random ID (discord style)
 * @returns string
 */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;randomId&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;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;substring&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="mi"&gt;6&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;
  
  
  Formats
&lt;/h2&gt;

&lt;p&gt;Most of the random lists will be in the following format &lt;code&gt;string[]&lt;/code&gt; however there will be specifications. For example teams will be composed in this format:&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="nx"&gt;adjective&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;noun&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For example:&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="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;icy-dinosaurs&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;mighty-scarecrow&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;aquatic-squirrels&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;defiant-camp&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;natural-memory&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;Then we have the Extended Colors which are of the following format:&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="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ExtendedColor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
    &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
    &lt;span class="nx"&gt;hex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
    &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;
    &lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;
    &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;To use the library you simply need to do the following:&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="nx"&gt;yarn&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;pixium&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;digital&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;namer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then you can use it like this:&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;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;RandomNamer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RandomType&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@pixium-digital/random-namer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;RandomNamer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;RandomType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TEAM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;toGenerate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;allUnique&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;addId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// ['voiceless-sea#4457', 'delicate-star#6563', 'even-nest#9988']&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;RandomNamer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;RandomType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GAMERTAG&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;toGenerate&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="c1"&gt;// ['The Best Yoda', 'I_Cant_Play']&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Link
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/pixiumdigital"&gt;
        pixiumdigital
      &lt;/a&gt; / &lt;a href="https://github.com/pixiumdigital/random-namer"&gt;
        random-namer
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Simple random name generator for various utilities
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Random Namer&lt;/h1&gt;
&lt;p&gt;This project aims to simply provide random usernames, team names, gamertags, adjectives, colors to use in testing data.&lt;/p&gt;
&lt;h2&gt;
Installation&lt;/h2&gt;
&lt;div class="highlight highlight-source-ts position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-s1"&gt;yarn&lt;/span&gt; &lt;span class="pl-s1"&gt;install&lt;/span&gt; @&lt;span class="pl-s1"&gt;pixium&lt;/span&gt;&lt;span class="pl-c1"&gt;-&lt;/span&gt;&lt;span class="pl-s1"&gt;digital&lt;/span&gt;&lt;span class="pl-c1"&gt;/&lt;/span&gt;&lt;span class="pl-s1"&gt;random&lt;/span&gt;&lt;span class="pl-c1"&gt;-&lt;/span&gt;&lt;span class="pl-s1"&gt;namer&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
Usage&lt;/h2&gt;
&lt;div class="highlight highlight-source-ts position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-smi"&gt;RandomNamer&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-smi"&gt;RandomType&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt; &lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s"&gt;"@pixium-digital/random-namer"&lt;/span&gt;
&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;list&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-smi"&gt;RandomNamer&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-smi"&gt;RandomType&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;TEAM&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-c1"&gt;toGenerate&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-c1"&gt;allUnique&lt;/span&gt;: &lt;span class="pl-c1"&gt;true&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-c1"&gt;addId&lt;/span&gt;: &lt;span class="pl-c1"&gt;true&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;
&lt;span class="pl-c"&gt;// ['voiceless-sea#4457', 'delicate-star#6563', 'even-nest#9988']&lt;/span&gt;

&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;list&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-smi"&gt;RandomNamer&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-smi"&gt;RandomType&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;GAMERTAG&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-c1"&gt;toGenerate&lt;/span&gt;: &lt;span class="pl-c1"&gt;2&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;
&lt;span class="pl-c"&gt;// ['The Best Yoda', 'I_Cant_Play']&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Here is the list of random types that can be passed:&lt;/p&gt;
&lt;div class="highlight highlight-source-ts position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;export&lt;/span&gt; &lt;span class="pl-k"&gt;enum&lt;/span&gt; &lt;span class="pl-smi"&gt;RandomType&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
    &lt;span class="pl-c1"&gt;ADJECTIVE&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;COLOR&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;EXTENDED_COLOR&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;GAMERTAG&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;NOUN&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;TEAM&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Here are the parameters available to pass to the function&lt;/p&gt;
&lt;div class="highlight highlight-source-ts position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-kos"&gt;{&lt;/span&gt;
    toGenerate: &lt;span class="pl-s1"&gt;number&lt;/span&gt; &lt;span class="pl-c"&gt;// Number of items to generate&lt;/span&gt;
    &lt;span class="pl-s1"&gt;allUnique&lt;/span&gt;?: &lt;span class="pl-s1"&gt;boolean&lt;/span&gt; &lt;span class="pl-c"&gt;// Should the generated items be unique?&lt;/span&gt;
    &lt;span class="pl-s1"&gt;addId&lt;/span&gt;?: &lt;span class="pl-s1"&gt;boolean&lt;/span&gt; &lt;span class="pl-c"&gt;//&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/pixiumdigital/random-namer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Pixium Digital&lt;/strong&gt; - Shaping your project with technology and innovation&lt;br&gt;
&lt;a href="https://pixiumdigital.com"&gt;https://pixiumdigital.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/pixiumdigital"&gt;https://github.com/pixiumdigital&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How we handled 350+ online connections on a video game </title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Mon, 20 Sep 2021 03:21:28 +0000</pubDate>
      <link>https://dev.to/pixiumdigital/how-we-handled-350-online-connections-on-a-video-game-8ak</link>
      <guid>https://dev.to/pixiumdigital/how-we-handled-350-online-connections-on-a-video-game-8ak</guid>
      <description>&lt;p&gt;We were working with a client on building a video game that had multiplayer integrated.&lt;/p&gt;

&lt;p&gt;The game is more of a tabletop turn based game (think monopoly, life). We had to make sure turns and actions were synchronized across the board. &lt;/p&gt;

&lt;p&gt;Furthermore we had the restraint that only one of the players is essentially the one enables to perform the actions. This means we had to account for scenarios where the client would be disconnected and we had to pass the power of decision to another user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EZnApA7U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/80W1ntjiBxAAAAAd/jim-carrey-ive-got-the-power.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EZnApA7U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/80W1ntjiBxAAAAAd/jim-carrey-ive-got-the-power.gif" alt="I got the power"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the stack
&lt;/h2&gt;

&lt;p&gt;Having had some experience with game jams and other multiplayer games we decided to go with a typescript server leveraging &lt;a href="https://socket.io/"&gt;Socket.IO&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This would let use easily create a client / server using the same typescript types for exchanging data information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7rIia-wK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/7Fa0cWtkMRAAAAAC/mail-download.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7rIia-wK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/7Fa0cWtkMRAAAAAC/mail-download.gif" alt="sending"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Session Context
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;First we wanted to setup our context. This means we could then interact with any game session or client data throughout any Socket.IO event.&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="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;SessionContext&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;activeSessions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;GameSession&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;clientSockets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeSessions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clientSockets&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we can see our context is consisted of &lt;code&gt;activeSessions&lt;/code&gt; and &lt;code&gt;clientSockets&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;clientSockets&lt;/code&gt; is just an array of strings of the ids of each clients connection. This is used later on on handling disconnection.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;activeSessions&lt;/code&gt; are were we have a list of game session. We use here the type &lt;code&gt;Record&lt;/code&gt; as this lets us access information on a faster scale with just the following:&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mySession&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sessionContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeSessions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;sessionId&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our class then had a few extra functions that don't need explanation such as (addActiveSession, getSessionByClientSocket, etc.)&lt;/p&gt;

&lt;h3&gt;
  
  
  Handling Disconnections
&lt;/h3&gt;

&lt;p&gt;It was important for us to handle disconnections as if a &lt;strong&gt;client in power&lt;/strong&gt;  gets disconnected we want to give that power to someone else.&lt;/p&gt;

&lt;p&gt;This is where the &lt;code&gt;clientSockets&lt;/code&gt; comes in as it lets us do a difference with the list of clients handled by Socket.IO. This is needed as the disconnect event does not tell us exactly who disconnected.&lt;/p&gt;

&lt;p&gt;We can then have something like this:&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="nx"&gt;reconcileDisconnect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ioClients&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nx"&gt;io&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SocketIO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Compare the list of the IO Server clients vs the one we stored&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;disconnectedClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clientSockets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;ioClients&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="c1"&gt;// If we have more than one disconnected user then we have discrepancy&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;disconnectedClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Loop through all the disconnected clients&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;disconnectedClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&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="c1"&gt;// Init local variables for easy access&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tmpClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;disconnectedClient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&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;sessionOfDisconnected&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getSessionByClientSocket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tmpClient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="c1"&gt;// If disconnected client was in a session&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sessionOfDisconnected&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tmpSession&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeSessions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;sessionOfDisconnected&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;GM : &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;master&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="c1"&gt;// Remove him from the GameSession Client list&lt;/span&gt;
                &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clients&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;tmpClient&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="c1"&gt;// Remove him from the global pool of connections&lt;/span&gt;
                &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clientSockets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clientSockets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tmpClient&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="c1"&gt;// Check if there are no more clients in the GameSession&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clients&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="c1"&gt;// Delete GameSession if there are no more users&lt;/span&gt;
                    &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeSessions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;sessionOfDisconnected&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="c1"&gt;// Check if he was has power&lt;/span&gt;
                    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasPower&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;tmpClient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                        &lt;span class="c1"&gt;// Log a message if we switched master&lt;/span&gt;
                        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;switchMaster&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                            &lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Power of the Session (&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;) has been changed to Client (&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasPower&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;)`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                            &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newPowerClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getClientFromSocketId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasPower&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                            &lt;span class="nx"&gt;tmpSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;broadcast&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;newGameMaster&lt;/span&gt;&lt;span class="dl"&gt;"&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="nx"&gt;newPowerClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;io&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&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="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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we now have a new person in power or our session deleted if the  person was the last user in the session.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oUbTfutr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/gWBNAo7iGOYAAAAd/lucifer-devil.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oUbTfutr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/gWBNAo7iGOYAAAAd/lucifer-devil.gif" alt="power"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;We have a few other functions for getting and setting information but the main point of this article was to show how to handle identity of disconnections and how to access data efficiently using context.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Pixium Digital&lt;/strong&gt; - Shaping your project with technology and innovation&lt;br&gt;
&lt;a href="https://pixiumdigital.com"&gt;https://pixiumdigital.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/pixiumdigital"&gt;https://github.com/pixiumdigital&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>beginners</category>
      <category>socket</category>
    </item>
    <item>
      <title>Deploying React with Express with route integrity</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Wed, 25 Aug 2021 03:36:34 +0000</pubDate>
      <link>https://dev.to/pixiumdigital/deploying-react-with-express-with-route-integrity-2op5</link>
      <guid>https://dev.to/pixiumdigital/deploying-react-with-express-with-route-integrity-2op5</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;As you may or may not know React often uses routing through the browser &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/History"&gt;history API&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;A few of the common libraries that you might encounter would  be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React Router DOM: &lt;a href="https://www.npmjs.com/package/react-router-dom"&gt;https://www.npmjs.com/package/react-router-dom&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Wouter: &lt;a href="https://www.npmjs.com/package/wouter"&gt;https://www.npmjs.com/package/wouter&lt;/a&gt; (personal favorite)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These libraries will let you define routes and which components are being rendered.&lt;/p&gt;

&lt;p&gt;Quick Example:&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/about&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;AboutPage&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Route&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/user/:id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;UserPage&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Route&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running this in dev mode will work fine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jA5zhK15--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/kwv_MuCidz8AAAAM/yes-will-ferrell.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jA5zhK15--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/kwv_MuCidz8AAAAM/yes-will-ferrell.gif" alt="awesome"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Issue
&lt;/h2&gt;

&lt;p&gt;If you build the react app and try to host it with express you'll notice we run in an issue:&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;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;express&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;express&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;configuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buildDirectory&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Server started on port 8080`&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;If you navigate to &lt;a href="http://127.0.0.1:8080"&gt;http://127.0.0.1:8080&lt;/a&gt; you'll see your react app.&lt;/p&gt;

&lt;p&gt;However if you navigate to &lt;a href="http://127.0.0.1:8080/about"&gt;http://127.0.0.1:8080/about&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will receive an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Can't GET /about
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--diAfG_iA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/4Ch9kTLVFJUAAAAC/well-this-brain-is-not-working-squidward.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--diAfG_iA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/4Ch9kTLVFJUAAAAC/well-this-brain-is-not-working-squidward.gif" alt="not working"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Solving the Issue
&lt;/h2&gt;

&lt;p&gt;Our issue comes from the fact that express will only allow the route '/' to be used.&lt;/p&gt;

&lt;p&gt;The idea is that we want to preserve the routes but still display our built &lt;code&gt;index.html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For this we can add the following statement:&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sendFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;configuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buildDirectory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&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;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&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="nx"&gt;err&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means that for every route we will render the &lt;code&gt;index.html&lt;/code&gt; however since we are not redirecting we will preserve the URL scheme.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nZZgVkpy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/ul_Bdn13nnQAAAAC/missionaccomplished-emperorsnewgroove.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nZZgVkpy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/ul_Bdn13nnQAAAAC/missionaccomplished-emperorsnewgroove.gif" alt="mission accomplished"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Pixium Digital&lt;/strong&gt; - Shaping your project with technology and innovation&lt;br&gt;
&lt;a href="https://pixiumdigital.com"&gt;https://pixiumdigital.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/pixiumdigital"&gt;https://github.com/pixiumdigital&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>tutorial</category>
      <category>typescript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>No need to open 4 tabs in your terminal for your projects!</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Fri, 09 Jul 2021 14:26:42 +0000</pubDate>
      <link>https://dev.to/pixiumdigital/no-need-to-open-4-tabs-in-your-terminal-for-your-projects-56h3</link>
      <guid>https://dev.to/pixiumdigital/no-need-to-open-4-tabs-in-your-terminal-for-your-projects-56h3</guid>
      <description>&lt;p&gt;Very often when working on full stack solutions we find ourselves opening 4+ tabs in our terminal. We would run a &lt;code&gt;yarn dev&lt;/code&gt; for on micro-service then a &lt;code&gt;yarn start&lt;/code&gt; for react and so on.&lt;/p&gt;

&lt;p&gt;This has always been annoying to handle and so we built &lt;code&gt;Child Manager&lt;/code&gt; which lets you manager child processes for your project from just a simple config file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pixiumdigital/child-manager/"&gt;https://github.com/pixiumdigital/child-manager/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;To install run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add @pixium-digital/child-manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use NPM&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @pixium-digital/child-manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Run
&lt;/h2&gt;

&lt;p&gt;To leverage child manager simply add a configuration file to your project (see below for config details)&lt;/p&gt;

&lt;p&gt;You can run thew following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn child-manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default the loaded config will be at the source of the project and be named &lt;code&gt;childmanager.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you wish to load a different file just pass the config option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn child-manager --config="./myconfig.json"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;You can then access the manager at the following:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://localhost:7000"&gt;http://localhost:7000&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;Here is an example configuration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "processes": [
    {
      "name": "Test Service",
      "command": {
        "executor": "node",
        "args": ["TestService.js"],
        "path": "./src/service",
        "isWindows": false
      },
      "maxLogs": 200
    },
    {
      "name": "Service 2",
      "command": {
        "executor": "yarn",
        "args": ["start"],
        "path": "./other-project/service",
        "isWindows": false
      },
      "maxLogs": 200
    }
  ],
  "captureExit": true,
  "longLive": false,
  "debug": false
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Generic configurations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;debug&lt;/code&gt;: This will show more logs in the terminal in case something is not working&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;longLive&lt;/code&gt;: This is to force process to stay alive. Use carefully.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;captureExit&lt;/code&gt;: This binds the exit of child manager so that it will kill all childs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Process configurations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt;: The name of your service&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;maxLogs&lt;/code&gt;: The max number of logs to keep in memory (recommended 200)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;command&lt;/code&gt;: This houses the command line that will be launched&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;executor&lt;/code&gt;: The command executor (yarn, npm, node)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;args&lt;/code&gt;: Array or extra arguments that should be passed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;path&lt;/code&gt;: Where the command should be executed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;isWindows&lt;/code&gt;: Is this running on windows system? if yes paths and executors will be automatically changed to be compatible&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;With the use of one simple configuration file we are now able to launch all our mini services efficiently and with ease regardless of the fact that it might be a &lt;code&gt;yarn script&lt;/code&gt; a &lt;code&gt;npm script&lt;/code&gt; or even a command line &lt;/p&gt;

&lt;p&gt;If you wish to contribute feel free to check out the code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pixiumdigital/child-manager/"&gt;https://github.com/pixiumdigital/child-manager/&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  About Us
&lt;/h2&gt;

&lt;p&gt;Pixium Digital&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pixiumdigital.com"&gt;https://pixiumdigital.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pixiumdigital"&gt;https://github.com/pixiumdigital&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>showdev</category>
    </item>
    <item>
      <title>You do not need NPM to work with NodeJS</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Thu, 18 Mar 2021 11:25:41 +0000</pubDate>
      <link>https://dev.to/crimsonmed/you-do-not-need-npm-to-work-with-nodejs-1co1</link>
      <guid>https://dev.to/crimsonmed/you-do-not-need-npm-to-work-with-nodejs-1co1</guid>
      <description>&lt;h1&gt;
  
  
  &lt;center&gt; Introduction &lt;/center&gt;
&lt;/h1&gt;




&lt;p&gt;So I was just scrolling the feed as usual when I cam across an article where the tittle caught my eye:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;div class="ltag__link__content"&gt;
    &lt;div class="missing"&gt;
      &lt;h2&gt;Article No Longer Available&lt;/h2&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;I was reading the article and their was some interesting point but a lot of misunderstandings and non-comprehension of the JavaScript ecosystem.&lt;/p&gt;

&lt;p&gt;After trying to explain in the comments what was the difference between NPM and Node.JS I thought it would be better to just create a post to stop the share of false information and to try and enlighten people.&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;center&gt; Definitions &lt;/center&gt;
&lt;/h1&gt;




&lt;h2&gt;
  
  
  &lt;center&gt; JavaScript &lt;/center&gt;
&lt;/h2&gt;

&lt;p&gt;JavaScript, often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm.&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/JavaScript"&gt;src&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Node.JS
&lt;/h2&gt;

&lt;p&gt;Node.JS is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Node.js"&gt;src&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  NPM
&lt;/h2&gt;

&lt;p&gt;NPM is the default package manager for the JavaScript runtime environment Node.JS. It consists of a command line client, also called NPM, and an online database of public and paid-for private packages, called the NPM registry.&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Npm_(software)"&gt;src&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  &lt;center&gt; Corrected Assumptions &lt;/center&gt;
&lt;/h1&gt;


&lt;h2&gt;
  
  
  Node.JS Does not need NPM to function
&lt;/h2&gt;

&lt;p&gt;If we look at the post mentioned in the introduction we can see that it starts of talking about Node.JS and then switches to mention NPM as if they were the same. The post judges Node.JS on the the problems of NPM. &lt;/p&gt;

&lt;p&gt;This is a big mistake in itself. Looking at the definition of NodeJS as well as the source code it is clear the &lt;strong&gt;Node.JS itself DOES NOT use NPM&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Node.JS was created before NPM and had as a main goal to have a cross-platform environment for executing JavaScript as backend. Thus looking at the Node.JS source code we can easily see that its main languages are: JavaScript, Python and C++ (for bindings).&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/nodejs"&gt;
        nodejs
      &lt;/a&gt; / &lt;a href="https://github.com/nodejs/node"&gt;
        node
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Node.js JavaScript runtime ✨🐢🚀✨
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;
  &lt;a href="https://nodejs.org/" rel="nofollow"&gt;
    &lt;img alt="Node.js" src="https://camo.githubusercontent.com/720ed473d178f9380291709d2223860ade4f3c7bc368e3fea1ad057b8dc9c6f5/68747470733a2f2f6e6f64656a732e6f72672f7374617469632f696d616765732f6c6f676f2d6c696768742e737667" width="400"&gt;
  &lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Node.js is an open-source, cross-platform, JavaScript runtime environment. It
executes JavaScript code outside of a browser. For more information on using
Node.js, see the &lt;a href="https://nodejs.org/" rel="nofollow"&gt;Node.js Website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The Node.js project uses an &lt;a href="https://raw.githubusercontent.com/nodejs/node/master/./GOVERNANCE.md"&gt;open governance model&lt;/a&gt;. The
&lt;a href="https://openjsf.org/" rel="nofollow"&gt;OpenJS Foundation&lt;/a&gt; provides support for the project.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This project is bound by a &lt;a href="https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md"&gt;Code of Conduct&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;
Table of contents&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#support"&gt;Support&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#release-types"&gt;Release types&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#download"&gt;Download&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#current-and-lts-releases"&gt;Current and LTS releases&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#nightly-releases"&gt;Nightly releases&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#api-documentation"&gt;API documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#verifying-binaries"&gt;Verifying binaries&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#building-nodejs"&gt;Building Node.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#security"&gt;Security&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#contributing-to-nodejs"&gt;Contributing to Node.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#current-project-team-members"&gt;Current project team members&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#tsc-technical-steering-committee"&gt;TSC (Technical Steering Committee)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#collaborators"&gt;Collaborators&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#release-keys"&gt;Release keys&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/#license"&gt;License&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Support&lt;/h2&gt;
&lt;p&gt;Looking for help? Check out the
&lt;a href="https://raw.githubusercontent.com/nodejs/node/master/.github/SUPPORT.md"&gt;instructions for getting support&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
Release types&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Current&lt;/strong&gt;: Under active development. Code for the Current release is in the
branch for its major version number (for example
&lt;a href="https://github.com/nodejs/node/tree/v15.x"&gt;v15.x&lt;/a&gt;). Node.js releases a new
major version every 6 months, allowing for breaking changes. This happens in
April and October every year. Releases appearing each…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/nodejs/node"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;There is even a tutorial for building the source itself which means you still do not need NPM to build and run Node.JS as well as code in it.&lt;/p&gt;




&lt;h2&gt;
  
  
  NPM needs Node.JS to funtion
&lt;/h2&gt;

&lt;p&gt;If we look at the NPM source code we can see it is fully coded in JavaScript&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/npm"&gt;
        npm
      &lt;/a&gt; / &lt;a href="https://github.com/npm/cli"&gt;
        cli
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      the package manager for JavaScript
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a href="https://github.com/npm/cli/actions?query=workflow%3A%22Node+CI%22+branch%3Alatest"&gt;&lt;img src="https://camo.githubusercontent.com/f70de7fe6c2f43810fcc886100ea6f91b81846d13358d0825f9d06de06c2ca08/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6e706d2f636c692f4e6f646525323043492f6c6174657374" alt="GitHub Workflow Status (branch)"&gt;&lt;/a&gt; &lt;a href="https://coveralls.io/github/npm/cli?branch=latest" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/f4d246355d0a775fa211a0be30cee0594669309b93f789f2ae0677791a7070aa/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f6e706d2f636c692f6c6174657374" alt="Coveralls github branch"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
npm - a JavaScript package manager&lt;/h1&gt;
&lt;h3&gt;
Requirements&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/download/" rel="nofollow"&gt;&lt;strong&gt;Node.js&lt;/strong&gt; &lt;code&gt;v10&lt;/code&gt;&lt;/a&gt; or higher must be installed to run this program&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Installation&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;npm&lt;/code&gt;&lt;/strong&gt; comes bundled with &lt;a href="https://nodejs.org/" rel="nofollow"&gt;&lt;strong&gt;&lt;code&gt;node&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;, &amp;amp; most third-party distributions, by default. Officially supported downloads/distributions can be found at: &lt;a href="https://nodejs.org/en/download" rel="nofollow"&gt;nodejs.org/en/download&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
Direct Download&lt;/h4&gt;
&lt;p&gt;You can download &amp;amp; install &lt;strong&gt;&lt;code&gt;npm&lt;/code&gt;&lt;/strong&gt; directly from &lt;a href="https://npmjs.com/" rel="nofollow"&gt;&lt;strong&gt;npmjs&lt;/strong&gt;.com&lt;/a&gt; using our custom &lt;code&gt;install.sh&lt;/code&gt; script:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell js-code-highlight"&gt;
&lt;pre&gt;curl -qL https://www.npmjs.com/install.sh &lt;span class="pl-k"&gt;|&lt;/span&gt; sh&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
Node Version Managers&lt;/h4&gt;
&lt;p&gt;If you're looking to manage multiple versions of &lt;strong&gt;&lt;code&gt;node&lt;/code&gt;&lt;/strong&gt; &amp;amp;/or &lt;strong&gt;&lt;code&gt;npm&lt;/code&gt;&lt;/strong&gt;, consider using a "Node Version Manager" such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/nvm-sh/nvm"&gt;&lt;strong&gt;&lt;code&gt;nvm&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jasongin/nvs"&gt;&lt;strong&gt;&lt;code&gt;nvs&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/isaacs/nave"&gt;&lt;strong&gt;&lt;code&gt;nave&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tj/n"&gt;&lt;strong&gt;&lt;code&gt;n&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/volta-cli/volta"&gt;&lt;strong&gt;&lt;code&gt;volta&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nodenv/nodenv"&gt;&lt;strong&gt;&lt;code&gt;nodenv&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/asdf-vm/asdf-nodejs"&gt;&lt;strong&gt;&lt;code&gt;asdf-nodejs&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Usage&lt;/h3&gt;
&lt;div class="highlight highlight-source-shell js-code-highlight"&gt;
&lt;pre&gt;npm &lt;span class="pl-k"&gt;&amp;lt;&lt;/span&gt;command&lt;span class="pl-k"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
Links &amp;amp; Resources&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.npmjs.com/" rel="nofollow"&gt;&lt;strong&gt;Documentation&lt;/strong&gt;&lt;/a&gt; - Official docs &amp;amp; how-tos for all things &lt;strong&gt;npm&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;Note: you can also search docs locally with &lt;code&gt;npm help-search &amp;lt;query&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/npm/cli/issues"&gt;&lt;strong&gt;Bug Tracker&lt;/strong&gt;&lt;/a&gt; - Search or submit bugs against the CLI&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/npm/roadmap"&gt;&lt;strong&gt;Roadmap&lt;/strong&gt;&lt;/a&gt; - Track &amp;amp; follow along with our public roadmap&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/npm/feedback"&gt;&lt;strong&gt;Feedback&lt;/strong&gt;&lt;/a&gt; - Contribute ideas &amp;amp; discussion around the npm registry…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/npm/cli"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;For NPM to work on any Operating System it will require Node as that is what the packet manager was made to work with. This is even specified in the &lt;code&gt;README.md&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Node.js v10 or higher must be installed to run this program&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Lock files and NPM
&lt;/h2&gt;

&lt;p&gt;The article in the introduction does mention that lock files are important and on that part I totally agree. However lock files have become a standard already used in all big and structured files and even in CI / CD. Lock files have been around for more than a few years and are already industry standard we could say.&lt;/p&gt;

&lt;p&gt;A good article that explains this is the following. I believe this is what the author of the article in the introduction was trying to explain in his own terms:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://snyk.io/blog/what-is-package-lock-json/"&gt;https://snyk.io/blog/what-is-package-lock-json/&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;center&gt; Conclusions &lt;/center&gt;
&lt;/h1&gt;




&lt;p&gt;What should we keep in mind after this article? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.JS &lt;strong&gt;does not&lt;/strong&gt; need NPM to function&lt;/li&gt;
&lt;li&gt;NPM &lt;strong&gt;needs&lt;/strong&gt; Node.JS to function&lt;/li&gt;
&lt;li&gt;JavaScript &lt;strong&gt;does not&lt;/strong&gt; need NPM or Node.JS to function (can be served through web)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Burlet Mederic&lt;br&gt;
&lt;a href="https://medericburlet.com"&gt;https://medericburlet.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://mederic.me"&gt;https://mederic.me&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/crimson_med"&gt;https://twitter.com/crimson_med&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Protect your PRIVACY from the next Cambridge Analytica 🔒🕵</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Thu, 24 Dec 2020 02:26:15 +0000</pubDate>
      <link>https://dev.to/pixiumdigital/protect-your-privacy-from-the-next-cambridge-analytica-4hio</link>
      <guid>https://dev.to/pixiumdigital/protect-your-privacy-from-the-next-cambridge-analytica-4hio</guid>
      <description>&lt;p&gt;Nowadays there are data breaches on a daily basis. It has become the norm to see on the news that companies have been hacked. But some data breaches are worse than others!&lt;/p&gt;

&lt;p&gt;We have recently been reviewing all company and personal emails through websites such as &lt;a href="https://haveibeenpwned.com/"&gt;Have I Been Pwned&lt;/a&gt;. This website incorporates a massive amount of breached and leaks and let you check if your email has been pwned.&lt;/p&gt;

&lt;p&gt;One specific breach caught our attention: &lt;strong&gt;People Data Labs (PDL)&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  People Data Labs
&lt;/h1&gt;

&lt;p&gt;By looking at it's website they mention they have accumulated over &lt;strong&gt;2.5 billion profiles&lt;/strong&gt; from unique individuals.&lt;/p&gt;

&lt;p&gt;Here is a partial sample of available fields when using their API:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full name&lt;/li&gt;
&lt;li&gt;First name&lt;/li&gt;
&lt;li&gt;Middle name&lt;/li&gt;
&lt;li&gt;Last name&lt;/li&gt;
&lt;li&gt;Gender&lt;/li&gt;
&lt;li&gt;Birth year&lt;/li&gt;
&lt;li&gt;Birth date&lt;/li&gt;
&lt;li&gt;LinkedIn url &amp;amp; username&lt;/li&gt;
&lt;li&gt;Facebook url &amp;amp; username&lt;/li&gt;
&lt;li&gt;Twitter url &amp;amp; username&lt;/li&gt;
&lt;li&gt;GitHub url &amp;amp; username&lt;/li&gt;
&lt;li&gt;Work email&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is just a small subset of the data collected on individuals by PDL.&lt;/p&gt;

&lt;h1&gt;
  
  
  Protecting your privacy
&lt;/h1&gt;

&lt;p&gt;If you find yourself in the &lt;strong&gt;PDL&lt;/strong&gt; breach we would recommend that you ask you data to be deleted by PDL. With current Data Privacy laws they had to make an easy to use opt-out form.&lt;/p&gt;

&lt;p&gt;The form is available here: &lt;a href="https://www.peopledatalabs.com/opt-out-form"&gt;https://www.peopledatalabs.com/opt-out-form&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HOWEVER BE WARY&lt;/strong&gt; the phone number field is not mandatory and you don't have to fill it in to opt-out. The less data your share the better it always is.&lt;/p&gt;

&lt;p&gt;On a side note if you see your email on &lt;strong&gt;Have I Been Pwned&lt;/strong&gt; as part of other data breaches we would recommend to update all your passwords.&lt;/p&gt;




&lt;h1&gt;
  
  
  About Us
&lt;/h1&gt;

&lt;p&gt;Pixium Digital is an agile software development company with their headquarters located in Singapore. We focus on shaping our clients project from ideas to successful project launch.&lt;/p&gt;

&lt;p&gt;Cyber Security is a big part of any project we have to deliver. Very often we have been the witness of lack of awareness or caution from various providers or clients we have worked with. We aim to share those little tips to the community so that with everyone's effort, we can make the web a safer place.&lt;/p&gt;

</description>
      <category>privacy</category>
      <category>security</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>🔨 Build a web package with typescript! 🔥</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Fri, 27 Nov 2020 10:13:59 +0000</pubDate>
      <link>https://dev.to/pixiumdigital/build-a-web-package-with-typescript-3844</link>
      <guid>https://dev.to/pixiumdigital/build-a-web-package-with-typescript-3844</guid>
      <description>&lt;h1&gt;
  
  
  👋🏻 Introduction
&lt;/h1&gt;

&lt;p&gt;Here at Pixium we often find ourselves creating web packages for various websites. &lt;/p&gt;

&lt;p&gt;This means a simple package that you can integrate via the script tag and then use in your code for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://mycdn.a/latest/bundle.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;pixiumPackage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;helloWorld&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;During the development of this package we often find ourselves recreating all the &lt;code&gt;package.json&lt;/code&gt; scripts and information. Thus we decided to create a template that can easily be setup.&lt;/p&gt;

&lt;p&gt;In this post we will look at what tools we use and how we came to creating this kick-ass template!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/D7z8JfNANqahW/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/D7z8JfNANqahW/giphy.gif" alt="power gif"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  🔧 Tools Used
&lt;/h1&gt;

&lt;p&gt;Here is a quick list of tools used and a quick description of how it is used in the project&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Yarn&lt;/td&gt;
&lt;td&gt;Handle package installation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Npm&lt;/td&gt;
&lt;td&gt;Publish the package to npm registry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typescript&lt;/td&gt;
&lt;td&gt;Strongly typed JavaScript&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Webpack&lt;/td&gt;
&lt;td&gt;Bundle the typescript into a single JavaScript Library&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Snowpack&lt;/td&gt;
&lt;td&gt;Hot Module Reload for testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Concurrently&lt;/td&gt;
&lt;td&gt;Start multiple commands at the same time&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h1&gt;
  
  
  🗄️ Managing Structure
&lt;/h1&gt;

&lt;p&gt;Let's take a look now at how we manage folders and files in our current project&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/CTfg7SZKO10Pe/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/CTfg7SZKO10Pe/giphy.gif" alt="code gif"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;webpack-demo/
├── README.md
├── dist
├────...
├── node_modules
├────...
├── package.json
├── snowpack.config.js
├── src
├────...
├── &lt;span class="nb"&gt;test&lt;/span&gt;
├────...
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;As we can see we have 4 main folders in our project:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Folder&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;dist&lt;/td&gt;
&lt;td&gt;Contains compiled ready for release bundle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;node_modules&lt;/td&gt;
&lt;td&gt;All the npm packages needed for the project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;src&lt;/td&gt;
&lt;td&gt;The source files of the library&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;test&lt;/td&gt;
&lt;td&gt;A index file referencing the bundle to test in real time&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h1&gt;
  
  
  🕸 Webpack
&lt;/h1&gt;

&lt;p&gt;In this project we use &lt;a href="https://www.npmjs.com/package/webpack"&gt;webpack&lt;/a&gt; and &lt;a href="https://www.npmjs.com/package/ts-loader"&gt;ts-loader&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Webpack&lt;/code&gt; is used for bundling everything in a library that is exposed in the browser while &lt;code&gt;ts-loader&lt;/code&gt; let's us handle all the typescript necessities.&lt;/p&gt;

&lt;p&gt;For the webpack config we use the &lt;code&gt;output:library&lt;/code&gt; property to specify the name of the exposed library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;webpack.config.js&lt;/strong&gt;&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;rules&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="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;tsx&lt;/span&gt;&lt;span class="se"&gt;?&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ts-loader&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sr"&gt;/node_modules/&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="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;extensions&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;.tsx&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;.ts&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;.js&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="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Define the package name&lt;/span&gt;
        &lt;span class="na"&gt;library&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pixiumPackage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;libraryTarget&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;umd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;globalObject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;this&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bundle.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This means we can then access the library like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;pixiumPackage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;myFunctionName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;pixiumPackage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;myClassName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  ❄️️ Snowpack
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.snowpack.dev/"&gt;Snowpack&lt;/a&gt; is an awesome tool that we discovered recently at Pixium. It is a modern frontend build tool that is so fast!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/3ornjIhZGFWpbcGMAU/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/3ornjIhZGFWpbcGMAU/giphy.gif" alt="fast gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this project Snowpack has a very simple use. Rendering a test environment to visualize changes in real time. It supports Hot Module Replacement which means everytime webpack will recompile a new bundle after making some changes the test environment will reload&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RU7bryzy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ufcsgmnnibje99234y09.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RU7bryzy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ufcsgmnnibje99234y09.gif" alt="snowpack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;snowpack.config.js&lt;/strong&gt;&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="cm"&gt;/** @type {import("snowpack").SnowpackUserConfig } */&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;mount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/dist&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="na"&gt;plugins&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;@snowpack/plugin-typescript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;install&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="cm"&gt;/* ... */&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;installOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;installTypes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here the &lt;code&gt;mount&lt;/code&gt; parameter is the most important. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;test: '/',&lt;/code&gt; means we will mount the test folder as the root of the web&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dist: '/dist'&lt;/code&gt; means we will mount the dist folder to &lt;code&gt;/dist&lt;/code&gt;. This means that we can then require scripts from dist for instance &lt;code&gt;&amp;lt;script src="./dist/bundle.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  💻 Exposing our Code
&lt;/h1&gt;

&lt;p&gt;And now let's finish off with taking a look at the code and how we can expose our constants, functions, class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/PiQejEf31116URju4V/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/PiQejEf31116URju4V/giphy.gif" alt="typing gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make code accessible through our library we simply have to use the &lt;code&gt;export&lt;/code&gt; method. For instance:&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="cm"&gt;/**
 * Say hello world in the console
 */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PixiumHello&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;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`hello world`&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;We can then call this in the following way:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="nx"&gt;pixiumPackage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PixiumHello&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can also easily interact with the &lt;code&gt;DOM&lt;/code&gt; through classic functions:&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="c1"&gt;// Set the inner text&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="s2"&gt;pixiumBanner&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Pixium Digital Pte Ltd&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;h1&gt;
  
  
  🏁 Conclusion
&lt;/h1&gt;

&lt;p&gt;We now have a very simple typescript bundling in place with a HMR system in place for easy testing.&lt;/p&gt;

&lt;p&gt;There are a few command shortcuts implemented to easily push patches, minors, majors to npm.&lt;/p&gt;

&lt;p&gt;All this coupled with a CDN and you get an awesome blazing fast library for your frontend.&lt;/p&gt;

&lt;p&gt;Full repo bellow&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/pixiumdigital"&gt;
        pixiumdigital
      &lt;/a&gt; / &lt;a href="https://github.com/pixiumdigital/typescript-package-boilerplate"&gt;
        typescript-package-boilerplate
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      webpack package with typescript support
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Typescript Webpackage Boilerplate&lt;/h1&gt;
&lt;p&gt;In this boilerplate we have a simple look at a very basic typescript package exported for the web.&lt;/p&gt;
&lt;p&gt;We leverage the use of webpack to expose our package to the browser.&lt;/p&gt;
&lt;h1&gt;
Installation&lt;/h1&gt;
&lt;p&gt;install the dev packages with yarn:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;yarn
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;
Developement&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;yarn start
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will start webpack to compile the library on changes.
This will also start snowpack which will update the index.html in test once the library from webpack has been compiled&lt;/p&gt;
&lt;h1&gt;
Build&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;yarn build
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;
Publish Package&lt;/h1&gt;
&lt;p&gt;First login to the npm cli if not already done&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;npm login
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will need to remove the following line in your &lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;private: true,
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To publish a patch&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;yarn patch
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To publish a minor&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;yarn minor
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To publish a major&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;yarn major
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/pixiumdigital/typescript-package-boilerplate"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Pixium Digital&lt;/strong&gt; - Shaping your project with technology and innovation&lt;br&gt;
&lt;a href="https://pixiumdigital.com"&gt;https://pixiumdigital.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/pixiumdigital"&gt;https://github.com/pixiumdigital&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>devops</category>
    </item>
    <item>
      <title>Black Friday 🔥 Namecheap Deals</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Wed, 25 Nov 2020 10:53:18 +0000</pubDate>
      <link>https://dev.to/crimsonmed/black-friday-namecheap-deals-13p7</link>
      <guid>https://dev.to/crimsonmed/black-friday-namecheap-deals-13p7</guid>
      <description>&lt;p&gt;Hey fellow developers!&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;With black friday around the corner, Namecheap is now having some amazing black friday deals.&lt;/p&gt;

&lt;p&gt;Personally I have been using Namecheap for quite a while. After using service like godaddy, vodien and more and having encountered many issues, Namecheap is the domain provider that has been the most flexible and reliable.&lt;/p&gt;

&lt;h1&gt;
  
  
  Deals
&lt;/h1&gt;

&lt;p&gt;To view all deals you can go here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.namecheap.com/domain-web-hosting-ssl-deals/black-friday"&gt;https://www.namecheap.com/domain-web-hosting-ssl-deals/black-friday&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Domains
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;.net&lt;/strong&gt;&lt;br&gt;
54% off ($5.98/yr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.com&lt;/strong&gt;&lt;br&gt;
44% off ($4.98/yr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.io&lt;/strong&gt;&lt;br&gt;
21% off ($25.98/yr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.dev&lt;/strong&gt;&lt;br&gt;
27% off ($10.98/yr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.link&lt;/strong&gt;&lt;br&gt;
89% off ($0.98/yr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.online&lt;/strong&gt;&lt;br&gt;
97% off ($0.98/yr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.me&lt;/strong&gt; - my favorite &lt;a href="https://mederic.me"&gt;https://mederic.me&lt;/a&gt;&lt;br&gt;
90% off ($1.98/yr)&lt;/p&gt;

&lt;h2&gt;
  
  
  Private Email
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Starter&lt;/strong&gt; - 1 mail box + 5GB of Email + 2GB of File Space&lt;br&gt;
70% off ($3.56/yr)&lt;/p&gt;

&lt;h2&gt;
  
  
  SSL Certificates
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;PositiveSSL&lt;/strong&gt;&lt;br&gt;
51% off ($2.88/yr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PositiveSSL Wildcard&lt;/strong&gt;&lt;br&gt;
71% off ($20.88/yr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EssentialSSL&lt;/strong&gt;&lt;br&gt;
47% off ($6.88/yr)&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I hope that sharing this can help some developer launch their own products and projects. Do keep in mind by law some domain names require a ssl certificate to work (.dev, .io).&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>hosting</category>
      <category>cloud</category>
      <category>domain</category>
    </item>
    <item>
      <title>Vestigo v0.5.0 - Tales of Port Scans</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Tue, 03 Nov 2020 17:19:18 +0000</pubDate>
      <link>https://dev.to/crimsonmed/vestigo-v0-5-0-tales-of-port-scans-3kl7</link>
      <guid>https://dev.to/crimsonmed/vestigo-v0-5-0-tales-of-port-scans-3kl7</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;After other side projects and less free time I had to leave Vestigo for a while&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/crimsonmed" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--93MWdqLK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--jPqp8HbV--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/187045/096e2d89-d8ea-4637-a577-d2fab7bbb1fd.jpg" alt="crimsonmed image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/crimsonmed/discovering-vulnerable-endpoints-on-api-websites-67g" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Discovering vulnerable endpoints on API / Websites&lt;/h2&gt;
      &lt;h3&gt;Médéric Burlet ・ Mar  9 ・ 2 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#security&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#api&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#devops&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#testing&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;With Hacktoberfest I decided to revisit this project and start to make it into something useful. When doing simple API tests I find myself often repeating the sames tasks. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NMAP on the target &lt;/li&gt;
&lt;li&gt;Rust Scan&lt;/li&gt;
&lt;li&gt;DirBuster&lt;/li&gt;
&lt;li&gt;And more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea of Vestigo is to have a one tool that does all this with ease.&lt;/p&gt;

&lt;h1&gt;
  
  
  v0.5.0
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Scan
&lt;/h2&gt;

&lt;p&gt;Since the last update on Vestigo on dev.to there have been a few updates to the Scan command. It will now save reports in HTML and MD.&lt;/p&gt;

&lt;p&gt;Those reports will be saved on the user profile &lt;code&gt;~/.vestigo&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The scan comes with a whois module&lt;/p&gt;

&lt;h2&gt;
  
  
  Ports
&lt;/h2&gt;

&lt;p&gt;v0.5.0 introduces the ports command which lets you portscan a target that is either an ip or a domain.&lt;/p&gt;

&lt;p&gt;As of now only TCP scan has been integrated. But I plan to add UDP + reporting for this module.&lt;/p&gt;

&lt;p&gt;I also want to add the possibility to try to curl the ports that possibly have a webserver. And in the future be able to detect the stack (wordpress, react, etc.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YIAo2qL---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rnjpz9ux4f5tw3pg0sja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YIAo2qL---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rnjpz9ux4f5tw3pg0sja.png" alt="port scan"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vestigo ports &lt;span class="nt"&gt;--target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Going forward
&lt;/h1&gt;

&lt;p&gt;The project is open source and on github so anyone wanting to participate in the development of this tool don't hesitate to open an issue based on the TO-DO list in the README.md with what you would like to tackle.&lt;/p&gt;

&lt;p&gt;I hope this project can help many and that it can find some support and love.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/crimson-med"&gt;
        crimson-med
      &lt;/a&gt; / &lt;a href="https://github.com/crimson-med/vestigo"&gt;
        vestigo
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A tool for exploring and investigating APIs and websites.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Vestigo&lt;/h1&gt;
&lt;p&gt;A tool for exploring and investigating APIs and websites.&lt;/p&gt;
&lt;h1&gt;
IMPORTANT&lt;/h1&gt;
&lt;p&gt;ocliff with npm and vestigo is broken to use the tool clone the repo&lt;/p&gt;
&lt;h1&gt;
Installation&lt;/h1&gt;
&lt;p&gt;You can install it globally with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;yarn global add vestigo
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;npm i -g vestigo
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then run the tool&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;vestigo
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;
Running&lt;/h1&gt;
&lt;p&gt;Scan Example:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell js-code-highlight"&gt;
&lt;pre&gt;vestigo scan --target=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;https://127.0.0.1/&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; --method=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;GET&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; --no-shortlist
  --report=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;HTML&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Port Example:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell js-code-highlight"&gt;
&lt;pre&gt;vestigo ports --target=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;127.0.0.1&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; --protocol=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;TCP&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; --report=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;HTML&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;As of now reports will be saved at:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;~/.vestigo/&amp;lt;domain&amp;gt;/&amp;lt;ts&amp;gt;-vestigo.&amp;lt;extension&amp;amp;gt
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;domain&amp;gt;&lt;/code&gt; = hostname of the target or the ip&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;ts&amp;gt;&lt;/code&gt; = timestamp of the scan finished&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;extension&amp;gt;&lt;/code&gt; = extension chosen for report (md, html)&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
Functionalities&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/crimson-med/vestigo/master/doc/SCAN.md"&gt;SCAN (webserver endpoint detection)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/crimson-med/vestigo/master/doc/PORTS.md"&gt;PORTS (port scanner)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
Report&lt;/h1&gt;
&lt;p&gt;Vestigo will by default generate a mardown report. You can use parameters to set the report format to HTML.&lt;/p&gt;
&lt;h1&gt;
Dev Run&lt;/h1&gt;
&lt;p&gt;To run the tool in dev mode use:&lt;/p&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/crimson-med/vestigo"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;






&lt;p&gt;Burlet Mederic&lt;br&gt;
&lt;a href="https://medericburlet.com"&gt;https://medericburlet.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://mederic.me"&gt;https://mederic.me&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/crimson_med"&gt;https://twitter.com/crimson_med&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>news</category>
      <category>devops</category>
      <category>javascript</category>
    </item>
    <item>
      <title>React, Prisma, GraphQL Boilerplate</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Sun, 11 Oct 2020 09:37:19 +0000</pubDate>
      <link>https://dev.to/crimsonmed/react-prisma-graphql-boilerplate-4c1e</link>
      <guid>https://dev.to/crimsonmed/react-prisma-graphql-boilerplate-4c1e</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;I find myself often recreating simple landing pages, login, logout, signup flows and I got really tired of it. Especially when its for small projects.&lt;/p&gt;

&lt;p&gt;I decided to make a nice easy to use boilerplate accessible for all.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&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%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/crimson-med" rel="noopener noreferrer"&gt;
        crimson-med
      &lt;/a&gt; / &lt;a href="https://github.com/crimson-med/react-prisma2-graphql-boilerplate" rel="noopener noreferrer"&gt;
        react-prisma2-graphql-boilerplate
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Simple React, Prisma2, GraphQL, Boilerplate
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;This project is open to Hacktoberfest contributions as long as the &lt;code&gt;CONTRIBUTING.md&lt;/code&gt; is respected.&lt;/p&gt;

&lt;h1&gt;
  
  
  Quick Start
&lt;/h1&gt;

&lt;p&gt;First:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/crimson-med/react-prisma2-graphql-boilerplate.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then follow the following instructions.&lt;/p&gt;

&lt;p&gt;Open two terminals and follow the following commands:&lt;/p&gt;




&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Terminal 1&lt;/th&gt;
&lt;th&gt;Terminal 2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;cd backend&lt;/td&gt;
&lt;td&gt;cd frontend&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;yarn install&lt;/td&gt;
&lt;td&gt;yarn install&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;yarn dev&lt;/td&gt;
&lt;td&gt;yarn start&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;That's it you are up and running!&lt;/p&gt;

&lt;h1&gt;
  
  
  Frontend
&lt;/h1&gt;

&lt;p&gt;In this frontend we leverage React for all the rendering. We also user OvermindJS for state management and ApolloClient for GraphQL interactions.&lt;/p&gt;

&lt;h1&gt;
  
  
  Backend
&lt;/h1&gt;

&lt;p&gt;An implementation of a GraphQL server with an email-password-based authentication workflow and authentication rules, based on Prisma, graphql-yoga, graphql-shield &amp;amp; Nexus Schema. It is based on a SQLite database.&lt;/p&gt;

&lt;p&gt;Since we are using prisma the database can easily be switched to anything (postgre, mysql, etc.)&lt;/p&gt;

&lt;h1&gt;
  
  
  Screenshots:
&lt;/h1&gt;

&lt;p&gt;Homepage:&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%2Fx90n00esuivurl7ykay9.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%2Fx90n00esuivurl7ykay9.png" alt="homepage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Login:&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%2Fraw.githubusercontent.com%2Fcrimson-med%2Freact-prisma2-graphql-boilerplate%2Fmaster%2Fdoc%2Flogin.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%2Fraw.githubusercontent.com%2Fcrimson-med%2Freact-prisma2-graphql-boilerplate%2Fmaster%2Fdoc%2Flogin.png" alt="login"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Signup:&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%2Fraw.githubusercontent.com%2Fcrimson-med%2Freact-prisma2-graphql-boilerplate%2Fmaster%2Fdoc%2Fsignup.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%2Fraw.githubusercontent.com%2Fcrimson-med%2Freact-prisma2-graphql-boilerplate%2Fmaster%2Fdoc%2Fsignup.png" alt="signup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dashboard:&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%2Fraw.githubusercontent.com%2Fcrimson-med%2Freact-prisma2-graphql-boilerplate%2Fmaster%2Fdoc%2Fdashboard.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%2Fraw.githubusercontent.com%2Fcrimson-med%2Freact-prisma2-graphql-boilerplate%2Fmaster%2Fdoc%2Fdashboard.png" alt="dashboard"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Burlet Mederic&lt;br&gt;
&lt;a href="https://medericburlet.com" rel="noopener noreferrer"&gt;https://medericburlet.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://mederic.me" rel="noopener noreferrer"&gt;https://mederic.me&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/crimson_med" rel="noopener noreferrer"&gt;https://twitter.com/crimson_med&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>graphql</category>
      <category>hacktoberfest</category>
    </item>
    <item>
      <title>How Array.fill can break arrays!</title>
      <dc:creator>Médéric Burlet</dc:creator>
      <pubDate>Wed, 07 Oct 2020 04:17:31 +0000</pubDate>
      <link>https://dev.to/crimsonmed/how-array-fill-can-break-arrays-3cdc</link>
      <guid>https://dev.to/crimsonmed/how-array-fill-can-break-arrays-3cdc</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;When working with arrays one should always be very careful in the difference between &lt;code&gt;Array.from&lt;/code&gt; and &lt;code&gt;Array.fill&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Array.fill
&lt;/h1&gt;

&lt;p&gt;It is very tempting to you &lt;code&gt;Array.fill&lt;/code&gt; as it has a much simpler syntax. However it is a nasty little beast when it comes to multi-dimensional array &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;Array.fill&lt;/code&gt; actually references the same object in memory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What does this mean?
&lt;/h2&gt;

&lt;p&gt;lets create a 5*5 multi dimensional array. This could be used for generating video games based on a cell system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This gives us the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ]
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Everything seems pretty ok until the moment we try to modify just one cell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;test&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This gives us the following output:&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
  [ '1', '5', '1', '1', '1' ],&lt;br&gt;
  [ '1', '5', '1', '1', '1' ],&lt;br&gt;
  [ '1', '5', '1', '1', '1' ],&lt;br&gt;
  [ '1', '5', '1', '1', '1' ],&lt;br&gt;
  [ '1', '5', '1', '1', '1' ]&lt;br&gt;
]&lt;/p&gt;
&lt;h2&gt;
  
  
  WAIT WHAT???
&lt;/h2&gt;

&lt;p&gt;Well by referencing the same object in memory that means all the cells in one column will change when changing one!&lt;/p&gt;
&lt;h1&gt;
  
  
  Array.from to the rescue
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;Array.from&lt;/code&gt; has a more iterative approach and does not reference same objects this means we will be able to modify anything.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;fixed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fixed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This gives us the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ]
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For now it looks the same but if we try to modify a cell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fixed&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fixed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We get the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  [ '1', '5', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ],
  [ '1', '1', '1', '1', '1' ]
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  WOHOOO
&lt;/h2&gt;

&lt;p&gt;Now we can create real multi-dimensional arrays&lt;/p&gt;




&lt;p&gt;Burlet Mederic&lt;br&gt;
&lt;a href="https://medericburlet.com"&gt;https://medericburlet.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://mederic.me"&gt;https://mederic.me&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/crimson_med"&gt;https://twitter.com/crimson_med&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
