<?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: Drakos</title>
    <description>The latest articles on DEV Community by Drakos (@devcrafter91).</description>
    <link>https://dev.to/devcrafter91</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%2F361256%2F4d1d597c-6794-4966-9ae2-381dc9c53cbb.jpg</url>
      <title>DEV Community: Drakos</title>
      <link>https://dev.to/devcrafter91</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devcrafter91"/>
    <language>en</language>
    <item>
      <title>Javascript Template Engines Benchmark (2024)</title>
      <dc:creator>Drakos</dc:creator>
      <pubDate>Sun, 02 Jun 2024 07:40:12 +0000</pubDate>
      <link>https://dev.to/devcrafter91/javascript-template-engine-benchmark-2024-2m3j</link>
      <guid>https://dev.to/devcrafter91/javascript-template-engine-benchmark-2024-2m3j</guid>
      <description>&lt;h2&gt;
  
  
  TLDR
&lt;/h2&gt;

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

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

&lt;p&gt;Template engines have long been a cornerstone of web development, enabling developers to dynamically generate HTML using logic and data. As the landscape of JavaScript library and framework options has expanded, so too has the variety of template engines available. This article explores the performance characteristics of several popular JavaScript template engines through rigorous benchmarking.&lt;/p&gt;

&lt;h2&gt;
  
  
  What tested
&lt;/h2&gt;

&lt;p&gt;The primary goal of a template engine is to separate the presentation layer from the business logic, making it easier to manage and maintain code. Given the rapid evolution of web applications and the intensive demands placed upon them, performance is a critical consideration. To help you make an informed decision, we will benchmark a selection of contemporary template engines:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Eta.js&lt;/li&gt;
&lt;li&gt;Liquid.js&lt;/li&gt;
&lt;li&gt;Handlebars&lt;/li&gt;
&lt;li&gt;Nunjucks&lt;/li&gt;
&lt;li&gt;EJS&lt;/li&gt;
&lt;li&gt;Edge.js&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Source
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/crafter999/template-engine-benchmarks"&gt;https://github.com/crafter999/template-engine-benchmarks&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Support
&lt;/h2&gt;

&lt;p&gt;If you liked this article follow me on Twitter, it's free!&lt;br&gt;
&lt;a href="https://twitter.com/devcrafter91"&gt;https://twitter.com/devcrafter91&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>ejs</category>
      <category>handlebars</category>
      <category>pug</category>
    </item>
    <item>
      <title>Publish private NPM packages securely with scopes on CodeArtifact</title>
      <dc:creator>Drakos</dc:creator>
      <pubDate>Mon, 13 Dec 2021 16:33:07 +0000</pubDate>
      <link>https://dev.to/devcrafter91/publish-private-npm-packages-securely-using-scopes-1k9f</link>
      <guid>https://dev.to/devcrafter91/publish-private-npm-packages-securely-using-scopes-1k9f</guid>
      <description>&lt;p&gt;NPM is a package manager configured by default to use the public registry but what if your code is proprietary and you want full disclosure? The easiest way is to use any cloud services (&lt;em&gt;that support private registries&lt;/em&gt;) like Github, Amazon Web Services, or Google Cloud.&lt;br&gt;
With just a few clicks you can setup a private registry for free. In this example, I'll be using CodeArtifact, I'm not affiliated in any way with Amazon Web Services, I had an account and didn't want to waste time trying other services. &lt;/p&gt;

&lt;p&gt;Disclaimer: I realize that people are dangerously messing up their environments and the most accurate way to prevent your modules from pushing to wrong servers is using NPM's scope packages. &lt;a href="https://docs.npmjs.com/cli/v7/using-npm/scope"&gt;https://docs.npmjs.com/cli/v7/using-npm/scope&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Install AWS CLI Version 2
&lt;/h2&gt;

&lt;p&gt;Pushing packages to CodeArtifact requires AWS authentication using the official CLI from Amazon, just run the following 3 commands to install it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;unzip awscliv2.zip&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;./aws/install # as root&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sudo installer -pkg AWSCLIV2.pkg -target /&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# /usr/local/bin/aws --version
aws-cli/2.2.47 Python/3.8.8 Linux/5.10.0-8-amd64 exe/x86_64.debian prompt/off

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setup an IAM user (API Keys)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to IAM &lt;a href="https://console.aws.amazon.com/iamv2/home#/users"&gt;https://console.aws.amazon.com/iamv2/home#/users&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;Add users&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;Access Key&lt;/code&gt; as credential type&lt;/li&gt;
&lt;li&gt;Create new group and give &lt;code&gt;AWSCodeArtifactAdminAccess&lt;/code&gt; permissions.&lt;/li&gt;
&lt;li&gt;Write down the generated &lt;code&gt;Access key ID&lt;/code&gt; &amp;amp; &lt;code&gt;Secret access key&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Login using the generated keys
&lt;/h2&gt;

&lt;p&gt;Running &lt;code&gt;aws configure&lt;/code&gt; will setup the AWS (needed for generating the NPM token later).&lt;/p&gt;

&lt;p&gt;**Don't forget to choose the default region. In this example I'm using Ireland EU.&lt;/p&gt;

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

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

AWS Access Key ID [None]: ----------------
AWS Secret Access Key [None]: ------------
Default region name [None]: eu-west-1
Default output format [None]: json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create a new NPM scope repo
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Login to the AWS dashboard.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;CodeArtifact&lt;/strong&gt; and click &lt;code&gt;Create repository&lt;/code&gt;. To avoid collisions give the scope repo a unique name like &lt;code&gt;ca-priv-repo-01&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Follow the instructions from AWS.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Publish &amp;amp; Pull the modules
&lt;/h2&gt;

&lt;p&gt;Here comes the hard part. The most valid &amp;amp; secure way to configure any project, is using scopes (namespaces).&lt;br&gt;
Publishing and pulling packages securely without messing up with global configuration  files which can lead to massive data leaks &amp;amp; terrible headaches. Thank to NPM's scopes, AWS will play fair with the package manager.&lt;/p&gt;

&lt;p&gt;Tip: Check the dummy project here &lt;a href="https://github.com/crafter999/private-npm-package"&gt;https://github.com/crafter999/private-npm-package&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Publish
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a fresh package using the AWS repository name as an NPM scope. For example &lt;code&gt;@ca-priv-repo-01/mypackage&lt;/code&gt;. Example package.json: &lt;code&gt;"name": "@ca-priv-repo-01/private-npm-package"&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Go to the CodeArtifact panel.&lt;/li&gt;
&lt;li&gt;Click on the target repository &amp;amp; then &lt;code&gt;View connection instructions&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;From there, select the &lt;code&gt;npm&lt;/code&gt; package manager.&lt;/li&gt;
&lt;li&gt;Choose &lt;code&gt;Manual Setup&lt;/code&gt;. (Skip &lt;code&gt;Recommended setup&lt;/code&gt; for the obvious reasons)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the first generated command on a terminal to export the CodeArtifact token.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example: 

export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain mydomain --domain-owner 00000000 --query authorizationToken --output text`
&lt;/code&gt;&lt;/pre&gt;




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

&lt;p&gt;Copy paste the 3 lines to the &lt;code&gt;.npmrc&lt;/code&gt; replacing &lt;code&gt;registry=&lt;/code&gt; with &lt;code&gt;@myscope:registry&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example: 
@ca-priv-repo-01:registry=https://-----------.amazonaws.com/npm/ca-priv-repo-01/
//-----------.amazonaws.com/npm/ca-priv-repo-01/:always-auth=true
//-----------.amazonaws.com/npm/ca-priv-repo-01/:_authToken=${CODEARTIFACT_AUTH_TOKEN}
&lt;/code&gt;&lt;/pre&gt;




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

&lt;p&gt;Add  the following lines to the &lt;code&gt;package.json&lt;/code&gt; replacing &lt;code&gt;---id---&lt;/code&gt; with te registry name.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"publishConfig"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"registry"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://---id---.codeartifact.eu-west-1.amazonaws.com/npm/ca-priv-repo-01/"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lastly, upload any package using &lt;code&gt;npm publish&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;NOTE 1: If you're getting authentication errors like the following one, make sure you successfully exported the &lt;code&gt;CODEARTIFACT_AUTH_TOKEN&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR! npm login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOTE 2: If you're getting domain errors like the following, make sure you are on the right region.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;An error occurred (ResourceNotFoundException) when calling the GetAuthorizationToken operation: Domain not found. Domain 'example' owned by account '0000000000' does not exist.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Pull
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a new project.&lt;/li&gt;
&lt;li&gt;Copy paste the &lt;code&gt;.npmrc&lt;/code&gt; from the previous step to root folder of your project.&lt;/li&gt;
&lt;li&gt;Export the token. Use the generated command from Connection Instructions (Manual Setup).&lt;/li&gt;
&lt;li&gt;Install using &lt;code&gt;npm install @myscope/mypackage&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Example Code
&lt;/h2&gt;

&lt;p&gt;You can find a dummy project here. &lt;a href="https://github.com/crafter999/private-npm-package"&gt;https://github.com/crafter999/private-npm-package&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Support
&lt;/h2&gt;

&lt;p&gt;If you liked this article please follow me on Twitter, it's free. &lt;a href="https://twitter.com/devcrafter91"&gt;https://twitter.com/devcrafter91&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Debug Node.js Typescript app using VS Code (Mac,Linux)</title>
      <dc:creator>Drakos</dc:creator>
      <pubDate>Thu, 05 Nov 2020 11:34:51 +0000</pubDate>
      <link>https://dev.to/devcrafter91/debug-node-js-with-typescript-on-linux-using-vscode-ilg</link>
      <guid>https://dev.to/devcrafter91/debug-node-js-with-typescript-on-linux-using-vscode-ilg</guid>
      <description>&lt;p&gt;Using the following configuration I managed to debug flawlessly Node.js applications written in Typescript using the Visual Studio Code IDE. I have tested it on Mac OS and almost every Linux distro like Debian, Ubuntu, Arch. &lt;/p&gt;

&lt;h3&gt;
  
  
  Configure tsconfig.json
&lt;/h3&gt;

&lt;p&gt;First of all, enable source maps &lt;code&gt;"sourceMap": true&lt;/code&gt; and declarations &lt;code&gt;"declarationMap": true&lt;/code&gt;, &lt;code&gt;"declaration": true&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Don't forget to specify the destination folder using the &lt;code&gt;outDir&lt;/code&gt; parameter.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure VSCODE
&lt;/h3&gt;

&lt;p&gt;Paste the following snippet and change &lt;code&gt;__MYAPP__&lt;/code&gt; to the typescript file you want to debug and &lt;code&gt;__MYDIST_FOLDER__&lt;/code&gt; to the dist folder of your project. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Don't forget to whitelist (OUTPUT) port 9229 locally on your iptables.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;code&gt;__MYAPP__&lt;/code&gt; = &lt;code&gt;src/app.ts&lt;/code&gt;&lt;br&gt;
&lt;code&gt;__MYDIST_FOLDER__&lt;/code&gt; = &lt;code&gt;dist&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"configurations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"launch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Debug Node.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"program"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"${workspaceFolder}/__MYAPP__.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"outFiles"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"${workspaceFolder}/__MYDIST_FOLDER__/**/*.js"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"sourceMaps"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;9229&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"runtimeArgs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"--inspect-brk=9229"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"console"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"integratedTerminal"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Support
&lt;/h3&gt;

&lt;p&gt;If you liked this quick guide follow me on Twitter :) &lt;a href="https://twitter.com/devcrafter91"&gt;https://twitter.com/devcrafter91&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>linux</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to install Kubernetes on Windows 10</title>
      <dc:creator>Drakos</dc:creator>
      <pubDate>Thu, 30 Jul 2020 22:23:50 +0000</pubDate>
      <link>https://dev.to/devcrafter91/how-to-install-kubernetes-on-windows-10-55b6</link>
      <guid>https://dev.to/devcrafter91/how-to-install-kubernetes-on-windows-10-55b6</guid>
      <description>&lt;h2&gt;
  
  
  Intro (Updated 17/07/2022)
&lt;/h2&gt;

&lt;p&gt;Kubernetes is made for managing your cloud resources and build scalable apps. It's considered the most popular tool for automating, deploying, and scaling your whole cloud. It runs on all major operating systems and it is the most popular open source tool in the cloud market. Kubernetes can scale your whole infrastructure, check the health of each service, work as a load balancer,  automate deployments and many more. You can install &amp;amp; setup as many nodes (clusters) as you want, and deploy your pods (docker containers) and services across the cloud. In this tutorial you will learn how to setup Kubernetes and deploy the official web GUI dashboard where you can manage and monitor everything but first you have to install Hyper-V &amp;amp; Docker in order to use Kubernetes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Install &amp;amp; Setup Hyper-V
&lt;/h2&gt;

&lt;p&gt;Windows as we all know, have their own virtualization software and it's called Hyper-V which is basically something like VirtualBox on steroids. Hyper-V can manage your virtual machines (VM) using the default GUI tool provided by Microsoft for free, or through command line. Enabling Hyper-V can be easily done but first, make sure your PC meets the following requirements: Your OS should be Windows 10 (Enterprise, Pro or Education) with minimum 4GB RAM and CPU  Virtualization support, although you have to double check if it's enabled in your BIOS settings.&lt;br&gt;&lt;br&gt;
You can remove or add features that don't come up pre-installed during the installation of Windows, like Hyper-V. Always remember that some of the features require internet access to download extra components from Windows Update. Follow the next steps to enable Hyper-V on your machine. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to Control Panel&lt;/li&gt;
&lt;li&gt;On your left panel, click on &lt;strong&gt;Programs&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Then click &lt;strong&gt;Programs and Features&lt;/strong&gt; followed by &lt;strong&gt;Turn Windows features on and off&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Check &lt;strong&gt;Hyper-V&lt;/strong&gt; and &lt;strong&gt;Windows Hypervisor Platform&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Your system will now start installing Hyper-V &lt;strong&gt;on the background&lt;/strong&gt;, it may need to reboot a couple of times until everything is configured properly. Don't expect any notification or something! Run the following powershelgl command as Administrator and verify if Hyper-V is installed successfully on your machine:  &lt;code&gt;Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V&lt;/code&gt;  &lt;/p&gt;

&lt;p&gt;Example.  &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\Windows\system32&amp;gt; Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V

FeatureName      : Microsoft-Hyper-V
DisplayName      : Hyper-V Platform
Description      : Provides the services that you can use to create and manage virtual machines and their resources.
RestartRequired  : Possible
State            : Enabled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 2: Install Docker for Windows
&lt;/h2&gt;

&lt;p&gt;Kubernetes is build on top of Docker, theoretically is just a tool that communicate with your Docker containers and manage everything on enterprise level. To install Docker just grab &amp;amp; run the following installer &lt;a href="https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe"&gt;https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe&lt;/a&gt; . During installation Docker will ask you to choose between Hyper-V and WSL. For better security &lt;strong&gt;uncheck WSL 2&lt;/strong&gt;. Docker will setup a Linux virtual machine on top of Hyper-V and start all the necessary services without manually configure anything. After the installation, you can either "communicate" with Docker using the CLI tool &lt;code&gt;docker&lt;/code&gt; or running HTTP requests though its API. &lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3: Install Kubernetes on Windows 10
&lt;/h2&gt;

&lt;p&gt;Docker comes with a handy GUI tool where you can modify some settings or install &amp;amp; enable Kubernetes. Follow the following instructions, WARNING! If Docker is installed successfully and you can't locate its tray icon, you have to reboot your system. If the problem persists, check the official troubleshooting guide here &lt;a href="https://docs.docker.com/docker-for-windows/troubleshoot/"&gt;https://docs.docker.com/docker-for-windows/troubleshoot/&lt;/a&gt;. Now follow the instructions to install Kubernetes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Right-click the Docker tray icon &lt;/li&gt;
&lt;li&gt;Click "Settings" &lt;/li&gt;
&lt;li&gt;On the left panel click "Kubernetes" &lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;Enable Kubernetes&lt;/code&gt; and click "Apply" &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;*** If you're behind a firewall, don't forget to allow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\program files\docker\docker\frontend\docker desktop.exe
C:\program files\docker\docker\resources\com.docker.backend.exe
C:\program files\docker\docker\resources\bin\kubectl.exe
C:\program files\docker\docker\resources\com.docker.vpnkit.exe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During installation, Docker is going to install additional packages and dependencies. It may take around 5~10 minutes and the installation time depends on your Internet speed and your PC performance. Wait until the 'Installation complete!' popup message is shown up. After installing Kubernetes you can make sure that everything is working fine using the Docker app. If both services (Docker &amp;amp; Kubernetes) are running successfully without any errors then both icons at bottom left will go green.&lt;/p&gt;

&lt;p&gt;Example.&lt;/p&gt;

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

&lt;p&gt;OR &lt;/p&gt;

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

&lt;h2&gt;
  
  
  Step 4: Install Kubernetes Dashboard
&lt;/h2&gt;

&lt;p&gt;Kubernetes Dashboard is the official web-based UI where you can manage Kubernetes resources. &lt;strong&gt;It's not installed by default&lt;/strong&gt;. Deploying applications with Kubernetes can be easily managed using the cli tool called &lt;code&gt;kubectl&lt;/code&gt; where you can interact with your cloud and manage your Pods, Nodes, or Clusters. If you pass the &lt;code&gt;apply&lt;/code&gt; argument followed by your YAML configuration file you can easily create or update Kubernetes resources. Run the following commands to deploy &amp;amp; enable the Kubernetes Dashboard using the following commands.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://github.com/kubernetes/dashboard/releases"&gt;https://github.com/kubernetes/dashboard/releases&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Scroll down to &lt;code&gt;Installation&lt;/code&gt; and download latest yaml configuration file for example &lt;a href="https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml"&gt;https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Deploy it using &lt;code&gt;kubectl apply -f .\recommended.yaml&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Verify that it's running using the following command: &lt;code&gt;kubectl.exe get -f .\recommended.yaml.txt&lt;/code&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\Users\user\Desktop&amp;gt; kubectl.exe get -f .\recommended.yaml.txt&lt;br&gt;
NAME                             STATUS   AGE&lt;br&gt;
namespace/kubernetes-dashboard   Active   2m10s

&lt;p&gt;NAME                                  SECRETS   AGE&lt;br&gt;
serviceaccount/kubernetes-dashboard   1         2m10s&lt;/p&gt;

&lt;p&gt;NAME                           TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE&lt;br&gt;
service/kubernetes-dashboard   ClusterIP   10.97.3.127   &amp;lt;none&amp;gt;        443/TCP   2m9s&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Step 5: Access the dashboard&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;There are two ways to access the dashboard with tokens, the first one (deprecated, works only for older versions) is using the default token that was crated during the installation of Kubernetes and the second (more secure) way is by creating users, giving them permissions, and then get the generated token.&lt;/p&gt;

&lt;h3&gt;
  
  
  Newest version
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a new configuration file:&lt;br&gt;
&lt;strong&gt;dashboard-admin.yaml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploy it using &lt;code&gt;kubectl.exe apply -f .\dashboard-admin.yaml.txt&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate token using &lt;code&gt;kubectl.exe -n kubernetes-dashboard create token admin-user&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;kubectl proxy&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy paste the token to &lt;a href="http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/"&gt;http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Old version (deprecated)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Run the following command &lt;strong&gt;powershell&lt;/strong&gt; (not cmd) &lt;code&gt;((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Copy the generated token&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;kubectl proxy&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Open the following link on your browser: &lt;a href="http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/"&gt;http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;Token&lt;/code&gt; &amp;amp; paste the generated token&lt;/li&gt;
&lt;li&gt;Sign In&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;p&gt;If everything is configured properly you'll be able to see the dashboard and your cloud resources. From there you can do almost all the "hard" work without dealing with the CLI every time. You may sometimes get your hands dirty with the command line but if you don't understand the concept of Docker and Kubernetes or you don't have time to for maintaining your own cloud, it's better to stick with some PaaS providers that can cost you a fortune.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Support
&lt;/h2&gt;

&lt;p&gt;If you liked this article please follow me on Twitter :) &lt;br&gt;
&lt;a href="https://twitter.com/devcrafter91"&gt;https://twitter.com/devcrafter91&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>windows</category>
      <category>cloud</category>
      <category>docker</category>
    </item>
    <item>
      <title>Elegant way to check if a Promise is pending</title>
      <dc:creator>Drakos</dc:creator>
      <pubDate>Sun, 12 Jul 2020 19:20:42 +0000</pubDate>
      <link>https://dev.to/devcrafter91/elegant-way-to-check-if-a-promise-is-pending-577g</link>
      <guid>https://dev.to/devcrafter91/elegant-way-to-check-if-a-promise-is-pending-577g</guid>
      <description>&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;There's no solid way to check if a &lt;code&gt;Promise&lt;/code&gt; is pending or finished, at least not in Node.js, so I wrote this simple snippet back in few months ago while I was searching for a simple way. I couldn't' find anything with one line max that will check the state of a promise so I came up with this simple solution. I have posted this solution on StackOverflow too. It's nothing special just an elegant &amp;amp; hacky way but works flawlessly on every Node.js version from 8~14. It's not stable though and the rational solution here should be a native method inside V8's core to check if a promise is pending or not. &lt;/p&gt;

&lt;h1&gt;
  
  
  The trick
&lt;/h1&gt;

&lt;p&gt;If we take the whole object of a promise and inspect it  using the &lt;code&gt;inspect&lt;/code&gt; method from the native libraries of Node.js, we will get either &lt;code&gt;'Promise { &amp;lt;pending&amp;gt; }'&lt;/code&gt; while pending or &lt;code&gt;'Promise { undefined }'&lt;/code&gt; when finished.&lt;br&gt;
Now if we check the string for the word &lt;code&gt;pending&lt;/code&gt; we could define the state and check if a promise is pending or not using the following one line: &lt;code&gt;util.inspect(myPromise).includes("pending")&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here's an example to get you started:&lt;/em&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;util&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;util&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&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;ms&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;letmesleep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nf"&gt;setInterval&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;util&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inspect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;letmesleep&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pending&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="mi"&gt;1000&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;&lt;em&gt;Result&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Support
&lt;/h2&gt;

&lt;p&gt;If you liked this article please follow me on Twitter :) &lt;br&gt;
&lt;a href="https://twitter.com/devcrafter91"&gt;https://twitter.com/devcrafter91&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>promise</category>
      <category>node</category>
    </item>
  </channel>
</rss>
