<?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: Perlat Kociaj</title>
    <description>The latest articles on DEV Community by Perlat Kociaj (@perlatsp).</description>
    <link>https://dev.to/perlatsp</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%2F136886%2Fb14c3c04-8726-4248-9be0-da060e48d400.jpeg</url>
      <title>DEV Community: Perlat Kociaj</title>
      <link>https://dev.to/perlatsp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/perlatsp"/>
    <language>en</language>
    <item>
      <title>How to  extract all the styles from an element</title>
      <dc:creator>Perlat Kociaj</dc:creator>
      <pubDate>Fri, 31 Jan 2020 23:55:45 +0000</pubDate>
      <link>https://dev.to/perlatsp/how-to-extract-all-the-styles-from-an-element-36bl</link>
      <guid>https://dev.to/perlatsp/how-to-extract-all-the-styles-from-an-element-36bl</guid>
      <description>&lt;h3&gt;
  
  
  TIL
&lt;/h3&gt;

&lt;p&gt;Today I learned something really cool. You can easily copy the CSS of an element from dev tools.&lt;br&gt;
Ever browsed a website and found a nice UI element and wanted to see/copy the CSS of it? Normally you would open dev tools and inspect that element to see the CSS and try to get all the style set some of them are set by class, some are inherited from the parent, you might have also inline styles. &lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Let's say for example on a blog page I want to see all the styles of the read more link on my blog page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1uCUW9QQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2es8pssd4dzaoi8rf2ib.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1uCUW9QQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2es8pssd4dzaoi8rf2ib.jpg" alt="blog page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get all the CSS for that link you can right-click to inspect it and then on the elements tab right-click on it again and click &lt;code&gt;Copy-&amp;gt;Copy styles&lt;/code&gt; &lt;/p&gt;

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

&lt;p&gt;Did you know this small trick?&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>css</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Introducing DEV.TO Gridsome Source Plugin </title>
      <dc:creator>Perlat Kociaj</dc:creator>
      <pubDate>Tue, 02 Jul 2019 21:00:43 +0000</pubDate>
      <link>https://dev.to/perlatsp/gridsome-source-plugin-for-dev-to-api-33cf</link>
      <guid>https://dev.to/perlatsp/gridsome-source-plugin-for-dev-to-api-33cf</guid>
      <description>&lt;p&gt;&lt;a href="https://www.npmjs.com/package/@perlatsp/gridsome-source-devto" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fgridsome--source--devto-0.0.1-brightgreen.svg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I just created a plugin for Gridsome, a source plugin to retrieve posts from using dev.to API.&lt;br&gt;
You are able to find the plugin on the NPM registry &lt;a href="https://www.npmjs.com/package/@perlatsp/gridsome-source-devto" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Gridsome?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkociaj.com%2Fcontent%2Fuploads%2F2019%2F07%2Fgridsome.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkociaj.com%2Fcontent%2Fuploads%2F2019%2F07%2Fgridsome.gif" alt="dev.to settins"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok, hold on a second! What is Gridsome? &lt;/p&gt;

&lt;p&gt;Glad you asked!&lt;/p&gt;

&lt;p&gt;Gridsome is a static site generator similar to Gatsby (though still new so not as feature-rich) for the &lt;a href="https://vuejs.org/" rel="noopener noreferrer"&gt;Vue&lt;/a&gt; framework. Gridsome makes it easy for developers to build modern JAMstack websites &amp;amp; PWAs that are fast by default. &lt;/p&gt;
&lt;h2&gt;
  
  
  Why Gridsome?
&lt;/h2&gt;

&lt;p&gt;If you are going to use gridsome you have following by default: &lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local development with hot-reloading&lt;/strong&gt; - See code changes in real-time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data source plugins&lt;/strong&gt; - Connect to any popular Headless CMSs, APIs or Markdown-files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File-based page routing&lt;/strong&gt; - Quickly create and manage routes with files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Centralized data management&lt;/strong&gt; - Pull data into a local, unified GraphQL data layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vue.js for frontend&lt;/strong&gt; - A lightweight and approachable front-end framework.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-optimized code&lt;/strong&gt; - Get code-splitting and asset optimization out-of-the-box.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static files generation&lt;/strong&gt; - Deploy securely to any CDN or static web host.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;For more in-depth information about Gridsome please read the &lt;a href="https://gridsome.org/docs" rel="noopener noreferrer"&gt;docs&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to use this plugin?
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;To install this plugin you just need to add it as a dependency on your gridsome project. You can do it by running the following command on your terminal using &lt;code&gt;yarn&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add @perlatsp/gridsome-source-devto
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or if you prefer &lt;code&gt;npm&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @perlatsp/gridsome-source-devto
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the installation finishes you should be ready for the next step, which is configuring the plugin.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuration
&lt;/h3&gt;

&lt;p&gt;Before we continue configuring the plugin, what we need to do first is getting an API key from &lt;a href="https://dev.to"&gt;https://dev.to&lt;/a&gt;. To do so, we need to go to dev.to website, go to &lt;a href="https://dev.to/settings/account"&gt;account-&amp;gt;settings&lt;/a&gt; and then you should see an input box, add a description for the token and smash that &lt;code&gt;Generate Token&lt;/code&gt; button. After doing so, this might take a while for the token to be generated for you (circa &lt;code&gt;200ms&lt;/code&gt; depending on your internet connection 🤪). &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%2Fkociaj.com%2Fcontent%2Fuploads%2F2019%2F07%2Fdevtoapi.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%2Fkociaj.com%2Fcontent%2Fuploads%2F2019%2F07%2Fdevtoapi.png" alt="dev.to settins"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Configurration file
&lt;/h4&gt;

&lt;p&gt;When you get your token we can proceed to the next step. Adding the configuration to the &lt;code&gt;gridsome.config.js&lt;/code&gt; file. This file is where most of the gridsome configurations live. Open the configuration file and add the following to the &lt;code&gt;plugins&lt;/code&gt; array. Like the following&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="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;other&lt;/span&gt; &lt;span class="nx"&gt;gridsome&lt;/span&gt; &lt;span class="nx"&gt;plugins&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&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;@perlatsp/gridsome-source-devto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;typeName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Article&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DEVTO_USERNAME&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DEVTO_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/:slug&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="nx"&gt;rest&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What we did here is to tell gridsome to use our plugin &lt;code&gt;use: '@perlatsp/gridsome-source-devto'&lt;/code&gt; with an &lt;code&gt;options&lt;/code&gt; object. The options object is pretty straight forward, we are assigning a &lt;code&gt;typeName: 'Article'&lt;/code&gt;, this is the name of our 'post model' we will use this later to query the posts.&lt;/p&gt;

&lt;p&gt;We have &lt;code&gt;username:'DEVTO_USERNAME'&lt;/code&gt; which is the author's username we want to retrieve from the API.&lt;/p&gt;

&lt;h4&gt;
  
  
  ENV File
&lt;/h4&gt;

&lt;p&gt;API key variable, &lt;code&gt;apiKey: process.env.DEVTO_API_KEY&lt;/code&gt; which is getting the value from the &lt;code&gt;.env&lt;/code&gt; file for security reasons so don't have this in our codebase. We need to create a &lt;code&gt;.env&lt;/code&gt; file in our project root directory and add the following &lt;code&gt;DEVTO_API_KEY=THE_API_KEY_FROM_DEVTO_SITE&lt;/code&gt;. And the last configuration we need to do is the route. this will be the single post's URL display type. More about gridsome routing &lt;a href="https://gridsome.org/docs/routing/#routing" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now we are ready to roll to the next step displaying the posts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Posts
&lt;/h3&gt;

&lt;p&gt;To display the posts we need to head over to the &lt;code&gt;Index.vue&lt;/code&gt; file and modify the  component (if the component does not exist, create one) to reflect the following:&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;page-query&amp;gt;&lt;/span&gt;
query Home {
    allArticle {
      edges {
        node {
          id
          title
          published_at
          path
          description
          tag_list
          canonical_url
          cover_image
        }
      }
    }
  }
&lt;span class="nt"&gt;&amp;lt;/page-query&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a GraphQL query.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;GraphQL is a declarative query language especially useful for retrieving only the data you ask for. Which again will result in smaller bundles.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We are registering entities named &lt;code&gt;allArticle&lt;/code&gt; (&lt;strong&gt;all&lt;/strong&gt; + the &lt;strong&gt;typeName&lt;/strong&gt; we registered in our config file).&lt;/p&gt;

&lt;p&gt;There is no need to get all the data from our articles, so we are requesting some of the nodes (fields)  like id, title, description, etc.&lt;/p&gt;

&lt;p&gt;Ok, we have our loop query. now what? Is that it? &lt;/p&gt;

&lt;p&gt;Of course not! Now we need somehow to display the date we have. to do so, scroll up to the ` component. and modify it to reflect the following : &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;html&lt;br&gt;
  &amp;lt;template&amp;gt;&lt;br&gt;
    &amp;lt;Layout&amp;gt;&lt;br&gt;
      &amp;lt;h1&amp;gt; Gridsome source plugin for&lt;br&gt;
        &amp;lt;img src="https://d2fltix0v2e0sb.cloudfront.net/dev-badge.svg" height="30"&lt;br&gt;
          width="30"&amp;gt;&amp;lt;/h1&amp;gt;&lt;br&gt;
      &amp;lt;div v-for="{ node } in $page.allArticle.edges" :key="node.id"&amp;gt;&lt;br&gt;
        &amp;lt;h2&amp;gt; {{node.title}}&amp;lt;/h2&amp;gt;&lt;br&gt;
        {{node.description}}&lt;br&gt;
        &amp;lt;div&amp;gt;&lt;br&gt;
          &amp;lt;g-link :to="node.path" class="single-post-link"&amp;gt;Read More&amp;lt;/g-link&amp;gt;&lt;br&gt;
        &amp;lt;/div&amp;gt;&lt;br&gt;
      &amp;lt;/div&amp;gt;&lt;br&gt;
    &amp;lt;/Layout&amp;gt;&lt;br&gt;
  &amp;lt;/template&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And &lt;em&gt;voila&lt;/em&gt;  we can now see our posts! Open your terminal and run &lt;code&gt;yarn develop&lt;/code&gt; to compile and create a dev server. your project should be available on &lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you followed the previous steps you should have something similar to the following picture. Navigation on top, a heading and the loop with the posts displaying the title, description and the link to the post.&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%2Fkociaj.com%2Fcontent%2Fuploads%2F2019%2F07%2Fposts.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%2Fkociaj.com%2Fcontent%2Fuploads%2F2019%2F07%2Fposts.png" alt="postsindex"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Personally, I don't like how it is visually. Let us add some styles. &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%2Fkociaj.com%2Fcontent%2Fuploads%2F2019%2F07%2Fpostscards.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%2Fkociaj.com%2Fcontent%2Fuploads%2F2019%2F07%2Fpostscards.png" alt="postscards"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A bit better 😄 with simple cards. We have now finished the project and we can run &lt;code&gt;yarn build&lt;/code&gt; to generate all the static files and ready to deploy! ⛴&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This plugin is still in development and more work needs to be done. Such us displaying more data for the single article page. PRs more than welcome on &lt;a href="https://github.com/perlatsp/gridsome-source-devto" rel="noopener noreferrer"&gt;github&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>gridsome</category>
      <category>api</category>
      <category>showdev</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to create and publish NPM Packages</title>
      <dc:creator>Perlat Kociaj</dc:creator>
      <pubDate>Thu, 20 Jun 2019 22:42:45 +0000</pubDate>
      <link>https://dev.to/perlatsp/how-to-create-and-publish-npm-packages-54p3</link>
      <guid>https://dev.to/perlatsp/how-to-create-and-publish-npm-packages-54p3</guid>
      <description>&lt;p&gt;This article aims to learn what is npm what do we need to run/install npm packages and we will learn how we can create and publish a package to the npm registry and feel like a cool and badass developer 😎. &lt;/p&gt;

&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;What is NPM&lt;/li&gt;
&lt;li&gt;Requirements&lt;/li&gt;
&lt;li&gt;Our NPM Package&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What is NPM
&lt;/h3&gt;

&lt;p&gt;What is npm again? Well, NPM stands for &lt;strong&gt;N&lt;/strong&gt;ode &lt;strong&gt;P&lt;/strong&gt;ackage &lt;strong&gt;M&lt;/strong&gt;anager and as the authors define it on their &lt;a href="https://www.npmjs.com/about" rel="noopener noreferrer"&gt;website&lt;/a&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;npm is the package manager for &lt;a href="http://nodejs.org/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt;. It was created in 2009 as an &lt;a href="https://github.com/npm/npm" rel="noopener noreferrer"&gt;open source project &lt;/a&gt;to help JavaScript developers easily share packaged modules of code.&lt;/li&gt;
&lt;li&gt;The npm Registry is a public collection of packages of open-source code for Node.js, &lt;a href="http://www.ember-cli.com/" rel="noopener noreferrer"&gt;front-end web apps&lt;/a&gt;, &lt;a href="http://cordova.apache.org/" rel="noopener noreferrer"&gt;mobile apps&lt;/a&gt;, &lt;a href="https://tessel.io/" rel="noopener noreferrer"&gt;robots&lt;/a&gt;, &lt;a href="https://linerate.f5.com/" rel="noopener noreferrer"&gt;routers&lt;/a&gt;, and countless other needs of the JavaScript community.&lt;/li&gt;
&lt;li&gt;npm is the command line client that allows developers to install and publish those packages.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Our Package
&lt;/h3&gt;

&lt;p&gt;For the scope of this article, we will get step by step of the process of creating an npm package and publish it on the npm registry so other developers around the world can use our package.&lt;/p&gt;

&lt;p&gt;The package we are going to create is a simple CLI app that will accept an email as an argument and will check if that email has been found in public data breaches. To achieve this we will be making &lt;strong&gt;HTTP&lt;/strong&gt; requests to an external API, the haveibeenpawned.com website’s API. The name of our package? &lt;strong&gt;pawnhub&lt;/strong&gt; 🙄 😉&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;p&gt;To build our package we need the following&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A working Computer 💻 🤓 I will be using MacOS but the process is similar to all OS.&lt;/li&gt;
&lt;li&gt;A Code Editor 📜 (I use &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;Visual Studio Code &lt;/a&gt;or &lt;a href="https://www.jetbrains.com/webstorm/" rel="noopener noreferrer"&gt;WebStorm&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;NodeJS&lt;/a&gt; installed our system with NPM installed and&lt;/li&gt;
&lt;li&gt;Internet Connection&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Install NodeJS
&lt;/h3&gt;

&lt;p&gt;To install NodeJS on our system we can do it in many ways, I will demonstrate 2 of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install from official website
&lt;/h3&gt;

&lt;p&gt;Visit the official NodeJs website &lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt;, press the download button&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AZtGv4qJEsgLmCNbj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AZtGv4qJEsgLmCNbj.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the download is finished, open the file and follow the instructions to complete the installation. Doing so will install node and npm.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install using homebrew
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://brew.sh/" rel="noopener noreferrer"&gt;Homebrew&lt;/a&gt; is a package manager for MacOS or Linux.&lt;/p&gt;

&lt;p&gt;First, we need to install Homebrew (if not already installed).&lt;/p&gt;

&lt;p&gt;Open the terminal and run the 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;/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will download and install Homebrew for us.&lt;/p&gt;

&lt;p&gt;Then run &lt;code&gt;brew update&lt;/code&gt; to make sure Homebrew is up to date.&lt;/p&gt;

&lt;p&gt;To install Node we just simply run the below command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;To confirm we have installed Node and NPM on our system, we can run the following commands:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;node -v&lt;/code&gt; and &lt;code&gt;npm -v&lt;/code&gt; it will display the version we have just installed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AKYB6wuOfDJXYBagW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AKYB6wuOfDJXYBagW.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the Package
&lt;/h3&gt;

&lt;p&gt;First, we need to create a directory for our project. I like to have all my projects in the &lt;code&gt;~/projects&lt;/code&gt; directory 🗂. Open the terminal and run &lt;code&gt;mkdir pawnhub&lt;/code&gt; this will create a folder named &lt;em&gt;pawnhub&lt;/em&gt;, then enter the directory &lt;code&gt;cd pawnhub&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  NPM Init
&lt;/h3&gt;

&lt;p&gt;Now that we are inside our project directory, we need to initialize an npm project. We can do that by running &lt;code&gt;npm init&lt;/code&gt;. This will start the interactive clip and ask us some information about our new package, such as the name, version, description, author, and license.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AeNQ5CF47TmtTlWln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AeNQ5CF47TmtTlWln.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we fill all the info we will be asked to confirm the information we have just entered.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AZWAH3ZD9p6w1EfCF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AZWAH3ZD9p6w1EfCF.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we need to open the project in our code editor. With Visual Studio Code we can run the command &lt;code&gt;code .&lt;/code&gt; which will open the current directory or we can open the Visual Studio Code and press COMMAND+O and open the dir.&lt;/p&gt;

&lt;p&gt;You will find that we have only 1 file the &lt;code&gt;package.json&lt;/code&gt;. More about the package.json file &lt;a href="https://docs.npmjs.com/files/package.json" rel="noopener noreferrer"&gt;here!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2ABqtAfDm0pfkrsY0z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2ABqtAfDm0pfkrsY0z.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Main File
&lt;/h3&gt;

&lt;p&gt;Our next step is to create the main file we are going to use, the &lt;code&gt;index.js&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;create the file in our root dir &lt;code&gt;touch index.js&lt;/code&gt;. Open the file and copy-paste the following :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let message = 'Hello World!';console.log(message)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running the file is pretty straightforward. Open the terminal and run &lt;code&gt;node index.js&lt;/code&gt; this will tell Node to run the index.js file. We should see the following on our terminal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AF4n7X9-1w6q3M0nK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AF4n7X9-1w6q3M0nK.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cool huh? But, it is not dynamic. we cannot change the outputted message! We will learn how to do so in the next section using arguments.&lt;/p&gt;

&lt;h3&gt;
  
  
  Node Arguments
&lt;/h3&gt;

&lt;p&gt;Normally, when we want to pass arguments we do the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;node filename argument1 argument2 argumentN....&lt;/code&gt; But the question is, how can you access these arguments ?&lt;/p&gt;

&lt;p&gt;The simplest way of retrieving arguments in Node.js is via the &lt;code&gt;process.argv&lt;/code&gt;array. This is a global object that we can use without importing any additional libraries to use it. These arguments can be accessed within the application via the &lt;code&gt;process.argv&lt;/code&gt; array. Let us start using arguments!&lt;/p&gt;

&lt;p&gt;Modify the file to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let message = 'Hello World!';console.log(process.argv)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and run &lt;code&gt;node index.js argument&lt;/code&gt; we will have something like the following image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AhJF_HQkeWtkW-TcA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AhJF_HQkeWtkW-TcA.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will have noticed that we have an array with 3 string items. I marked them with 0,1 and 2.&lt;/p&gt;

&lt;p&gt;The argument with key&lt;code&gt;0&lt;/code&gt; is the &lt;code&gt;node&lt;/code&gt; itself, argument &lt;code&gt;1&lt;/code&gt; is the file being executed and the last (&lt;code&gt;2&lt;/code&gt;) argument is the argument that we will be using in this tutorial.&lt;/p&gt;

&lt;p&gt;Ok, so now we need to do something with the last argument. Let’s display a customized message on the console.&lt;/p&gt;

&lt;p&gt;change the code to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name = process.argv[2];let message = `Hello ${name}`;console.log(process.argv)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What we did here is we initialize a variable called &lt;code&gt;name&lt;/code&gt; have a value from the third (key 2 as we start counting from 0 ) argument of the current process. Let’s run &lt;code&gt;node index.js Perlat&lt;/code&gt; (&lt;strong&gt;Perlat&lt;/strong&gt; is my name, so you can change this accordingly)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AW6_aGP3AOUCJSZ17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AW6_aGP3AOUCJSZ17.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Make it Executable
&lt;/h3&gt;

&lt;p&gt;So far so good, we have created our simple app, and we can run it by running &lt;code&gt;node index.js name&lt;/code&gt; but we need to be inside the directory for this to work. and we need to run every time the node and then the file, and then add an argument.&lt;/p&gt;

&lt;p&gt;How can we create an executable that will allow us to run the command from whatever directory?&lt;/p&gt;

&lt;p&gt;The answer is node binaries! And we can easily do this by adding a new field in the &lt;code&gt;package.json&lt;/code&gt; file, the &lt;code&gt;bin&lt;/code&gt; field. More info about the bin field &lt;a href="https://docs.npmjs.com/files/package.json#bin" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Now, add this inside your package.json, I usually add this just after the &lt;code&gt;main&lt;/code&gt;field.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"bin":{  "pawnhub":"./index.js"},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By doing so, we say to the node that we want to register a command named &lt;code&gt;pawnhub&lt;/code&gt; that will execute the &lt;code&gt;./index.js&lt;/code&gt; file upon running it. We can add multiple executables inside the bin file by specifying the name and the file to execute.&lt;/p&gt;

&lt;p&gt;If you are impatient and already ran the command &lt;code&gt;pawnhub name&lt;/code&gt; you will get an error &lt;code&gt;command not found: pawnhub&lt;/code&gt; this is because the command is not linked. We can do this by running &lt;code&gt;npm link&lt;/code&gt; inside our directory, and voila! our package is available symlinked globally on our system! Go ahead an try it. It will fail!&lt;/p&gt;

&lt;p&gt;The reason is that we need to add &lt;code&gt;#!/usr/bin/env node&lt;/code&gt; at the very top of the index.js file.&lt;/p&gt;

&lt;p&gt;By adding it, we are telling *nix systems that the interpreter of our JavaScript file should be &lt;code&gt;/usr/bin/env node&lt;/code&gt; which looks up for the locally-installed &lt;code&gt;node&lt;/code&gt;executable.&lt;/p&gt;

&lt;p&gt;In Windows, that line will just be ignored because it will be interpreted as a comment, but &lt;strong&gt;it has to be there&lt;/strong&gt; because &lt;code&gt;npm&lt;/code&gt; will read it on a Windows machine when the NodeJS command-line package is being installed. Now try again and it should be working fine!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AdxDyOcaGh_GDmyxG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AdxDyOcaGh_GDmyxG.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we have a package that is accepting arguments and can be accessed globally. We need to start working on our final package, making the HTTP requests to haveibeenpawned.com website.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Axios
&lt;/h3&gt;

&lt;p&gt;What is Axios?&lt;/p&gt;

&lt;p&gt;Axios is a promise based HTTP client for the browser and node.js. We can make requests such as GET, POST, DELETE or PUT. we are going to use only the GET request.&lt;/p&gt;

&lt;p&gt;More information about axios &lt;a href="https://github.com/axios/axios" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Because Axios is an npm package we can install it by running &lt;code&gt;npm install axios&lt;/code&gt; and it will be installed on our project. Axios can be used in browser applications as well by using a CDN or the path to the file like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://unpkg.com/axios/dist/axios.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Axios
&lt;/h3&gt;

&lt;p&gt;This is a simple GET request using axios! (modified from the example on the official docs)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const axios = require('axios');// Make a request for a user with a given IDaxios.get('ENDPOINT')  .then(function (response) {    // handle the response when it is a success    console.log(response);  })  .catch(function (error) {    // handle when error ocurrs (eg: 404)    console.log(error);  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Haveibeenpawned.com API
&lt;/h3&gt;

&lt;p&gt;Go ahead and try the &lt;a href="https://haveibeenpwned.com/" rel="noopener noreferrer"&gt;https://haveibeenpwned.com&lt;/a&gt; website (HIBP for abbreviation) and check if you have an account that has been compromised in a data breach. We will be using their API to achieve the functionality we desire.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://haveibeenpwned.com/API/v2" rel="noopener noreferrer"&gt;docs&lt;/a&gt; for using the API, for a reference.&lt;/p&gt;

&lt;p&gt;Ok, now let’s request HIBP API. Modify the &lt;code&gt;index.js&lt;/code&gt; to reflect the bellow code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env node
const axios = require('axios');
axios.get(`https://haveibeenpwned.com/api/v2/breachedaccount/admin@test.com`)
.then(response=&amp;gt;{
     console.log(response.data)
})
.catch(err=&amp;gt;{
    console.log(err)
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are calling the API to search the breached account for &lt;a href="//mailto:admin@test.com"&gt;admin@test.com&lt;/a&gt;email.&lt;/p&gt;

&lt;p&gt;Now run &lt;code&gt;pawnhub&lt;/code&gt; and you should get a big JSON object like the following sample.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2A9-WkuUb1tN8VklGw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2A9-WkuUb1tN8VklGw.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But we don’t need every information from that JSON object…&lt;/p&gt;

&lt;p&gt;Let us edit the file to reflect the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env node
const axios = require('axios');
axios.get(`https://haveibeenpwned.com/api/v2/breachedaccount/admin@test.com`)
.then(response=&amp;gt;{
let breaches=[]; //create empty array 
    console.log(`admin@test.com was found in ${ response.data.length} breaches!`) 
    //iterate each breaches to get only specific attributes
    response.data.forEach(breach =&amp;gt; {
        breaches.push({
            Name:breach.Name,
            Domain:breach.Domain,
            BreachDate:breach.BreachDate,
            AccountsHacked:breach.PwnCount,
        })
    });
    console.table(breaches) //display in pretty table! 😀 
})
.catch(err=&amp;gt;{
    console.log(err)//display error
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we should have a better representation of the data we got it should similar to the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AG60nLnYEZo5WVKLo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AG60nLnYEZo5WVKLo.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great, but this is not dynamic, we have hardcoded the email… How can we change this? Of course by using arguments!&lt;/p&gt;

&lt;p&gt;Let us modify the code to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env node
const axios = require('axios');
const email = process.argv[2] || 'admin@test.com'; //get the email from the arguments or set a default value
axios.get(`https://haveibeenpwned.com/api/v2/breachedaccount/${email}`)
.then(response=&amp;gt;{
let breaches=[]; //create empty array 
    console.log(`${email} was found in ${ response.data.length} breaches!`) 
    //iterate each breaches to get only specific attributes
    response.data.forEach(breach =&amp;gt; {
        breaches.push({
            Name:breach.Name,
            Domain:breach.Domain,
            BreachDate:breach.BreachDate,
            AccountsHacked:breach.PwnCount,
        })
    });
    console.table(breaches) //display in pretty table! 😀 
})
.catch(err=&amp;gt;{
    console.log(err)//display error
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We did it!&lt;/p&gt;

&lt;p&gt;We can now query the API for any email we want by running &lt;code&gt;pawnhub THE_EMAIL@DOMAIN.TLD&lt;/code&gt; and check if that email has been compromised! So now what? Well, now we need to do our final step, publish the package on the NPM registry!&lt;/p&gt;

&lt;h3&gt;
  
  
  Publish the Package
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Authenticate
&lt;/h3&gt;

&lt;p&gt;Well, for obvious reasons you need to create an account to be able to publish to the NPM registry!&lt;/p&gt;

&lt;p&gt;To create an account in the NPM registry click &lt;a href="https://www.npmjs.com/signup" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After creating an account, you need to authenticate our self by running the command &lt;code&gt;npm login&lt;/code&gt;, you would be prompted to provide our details, you need to enter the required details and you should log in!&lt;/p&gt;

&lt;p&gt;To test that the login was successful, enter the command &lt;code&gt;npm whoami&lt;/code&gt;, your username should be displayed to the CLI.&lt;/p&gt;

&lt;h3&gt;
  
  
  Publish
&lt;/h3&gt;

&lt;p&gt;Now the final step for our package to be available for the global community! Open the terminal and run the following inside the project directory &lt;code&gt;npm publish --access public&lt;/code&gt; this will publish the package with public access. and will be available on the npm registry. for this example, I have chosen the name to be &lt;code&gt;@perlatsp/pawnhub&lt;/code&gt; and is now available &lt;a href="https://www.npmjs.com/package/@perlatsp/pawnhub" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Make sure that you change the name inside the package.json file!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AaiLWgGiz9fylRByD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AaiLWgGiz9fylRByD.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boom!💥 Mission accomplished! ✅&lt;/p&gt;

&lt;p&gt;We have just learned how to create and publish an NPM package to the NPM registry. The next step is to improve our package by adding more features or fixing any bugs… 🐞&lt;/p&gt;

&lt;h3&gt;
  
  
  Test the Package
&lt;/h3&gt;

&lt;p&gt;Ok, we have published our package..how can we be sure that everything went as intended?&lt;/p&gt;

&lt;p&gt;Now on your terminal run &lt;code&gt;npm unlink&lt;/code&gt; to remove the symlink we have created on &lt;a href="https://kociaj.com/how-to-create-and-publish-npm-packages/#header-n610" rel="noopener noreferrer"&gt;this step&lt;/a&gt; and install our brand new package by running &lt;code&gt;npm install -g YOURPACKAGENAME&lt;/code&gt; I am using &lt;code&gt;npm install -g @perlatsp/pawnhub&lt;/code&gt;. We just installed our package and is globally available via &lt;code&gt;pawnhub&lt;/code&gt; (remember this is the package name that I set, yours should be different. Test it by running &lt;code&gt;pawnhub any@email.com&lt;/code&gt; and check the results. For this tutorial, we have not done anything for error handling, so in case the email is not valid or does not exist in any data breach you might get non handled errors.&lt;/p&gt;

&lt;p&gt;Now we have just finished this tutorial.&lt;/p&gt;

&lt;p&gt;Go and make some create tools and packages! 🙆‍♂️&lt;/p&gt;

&lt;p&gt;Let me know if you have any questions! ❓&lt;/p&gt;

&lt;p&gt;If you have followed this tutorial please do comment below the awesome tools you have created!&lt;/p&gt;

</description>
      <category>npm</category>
      <category>javascript</category>
      <category>api</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Web Development Environment using Devilbox</title>
      <dc:creator>Perlat Kociaj</dc:creator>
      <pubDate>Tue, 04 Jun 2019 08:19:24 +0000</pubDate>
      <link>https://dev.to/perlatsp/web-development-environment-using-devilbox-3k9k</link>
      <guid>https://dev.to/perlatsp/web-development-environment-using-devilbox-3k9k</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kpfE1FjZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/einstein.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kpfE1FjZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/einstein.jpg" alt="einstein" width="512" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've always been using WAMP as my local dev environment for a quite amount of time while I was using Windows OS, then I switched to Mac OS and used MAMP for a while. That was the case until one of my colleagues recommended &lt;code&gt;devilbox&lt;/code&gt;. I gave it a try, and since then I've been using it as my local dev environment.&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of Contents
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;What Is Devilbox&lt;/li&gt;
&lt;li&gt;Requirements&lt;/li&gt;
&lt;li&gt;&lt;a href="//#Configuring%20Devilbox%20.ENV%20FIle"&gt;Configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Project Directory&lt;/li&gt;
&lt;li&gt;WordPress Installation&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What is the Devilbox
&lt;/h3&gt;

&lt;p&gt;No, it does not has to do anything with the devil. As the author describes it in the official &lt;a href="http://devilbox.org/" rel="noopener noreferrer"&gt;website&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Devilbox is a modern and highly customizable &lt;strong&gt;dockerized PHP stack&lt;/strong&gt; supporting full &lt;strong&gt;LAMP&lt;/strong&gt; and &lt;strong&gt;MEAN&lt;/strong&gt; and running on all major platforms. The main goal is to easily switch and combine any version required for local development. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You don’t have to worry if your Operating System will support it. The Devilbox supports  &lt;strong&gt;Linux&lt;/strong&gt;, &lt;strong&gt;Mac&lt;/strong&gt;  and &lt;strong&gt;Windows&lt;/strong&gt; OS!&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%2F670ff5jaoxsrtt3lo6w3.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%2F670ff5jaoxsrtt3lo6w3.png" alt="Devilbox Dashboard" width="800" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Computer with decent specs&lt;/li&gt;
&lt;li&gt;Internet Connection&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.docker.com/" rel="noopener noreferrer"&gt;Docker&lt;/a&gt; Installed&lt;/li&gt;
&lt;li&gt;Git Installed &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I do believe I do not need to go through the first 2 requirements 😄 &lt;/p&gt;

&lt;p&gt;To use the Devilbox you will need to have Docker installed on your computer. For the sake of this article and because I am using Mac OS I will show you how to download and install Docker for Mac.&lt;/p&gt;

&lt;h4&gt;
  
  
  Install Docker
&lt;/h4&gt;

&lt;p&gt;There are many ways to install Docker for Mac&lt;/p&gt;

&lt;p&gt;One way is to head to &lt;a href="https://docs.docker.com/v17.12/docker-for-mac/install/#download-docker-for-mac" rel="noopener noreferrer"&gt;https://docs.docker.com/v17.12/docker-for-mac/install/#download-docker-for-mac&lt;/a&gt; and click &lt;code&gt;Get Docker for Mac&lt;/code&gt; (preferable version is always the stable). When the download is finished open the &lt;code&gt;Docker.dmg&lt;/code&gt; file you just downloaded and follow the instructions to complete the installation. &lt;/p&gt;

&lt;p&gt;The second is to install it via &lt;code&gt;homebrew&lt;/code&gt; the MacOS package manager. To install it open your terminal and type the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;~ brew &lt;span class="nb"&gt;install &lt;/span&gt;docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lYPDJWca--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/dockerinstall.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lYPDJWca--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/dockerinstall.png" alt="brew docker install" width="800" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next step is to run docker and the easiest way to do it is by pressing CMD + SPACE and type docker and then ENTER.  You should get a notification when docker is running.&lt;/p&gt;

&lt;h4&gt;
  
  
  Install Devilbox
&lt;/h4&gt;

&lt;p&gt;The Devilbox does not come with any install package, to &lt;em&gt;install&lt;/em&gt; it, you have to &lt;code&gt;clone&lt;/code&gt; the repository to your local machine. To achieve this, we use the command &lt;code&gt;git clone REPOSTIORY_URL.git&lt;/code&gt; the project's repo is hosted on &lt;a href="https://github.com/cytopia/devilbox" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. Let's proceed to install devilbox. &lt;br&gt;
Open a terminal window, and type &lt;code&gt;git clone https://github.com/cytopia/devilbox&lt;/code&gt;  and wait for the cloning process to finish. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4rmxqW8n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/devilboxinstall.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4rmxqW8n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/devilboxinstall.png" alt="devilboxinstalled" width="800" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the clone finishes and need to enter the devilbox directory by typing &lt;code&gt;cd devilbox&lt;/code&gt; you should see the following.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5b4vaySB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/devilboxinstalled.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5b4vaySB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/devilboxinstalled.png" alt="devilboxinstalled" width="800" height="662"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  .ENV file
&lt;/h4&gt;

&lt;p&gt;Because the Devilbox is configurable via a &lt;code&gt;.env&lt;/code&gt; file, our next step is to copy the &lt;code&gt;env-example&lt;/code&gt; file to &lt;code&gt;.env&lt;/code&gt; to so we can run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp &lt;/span&gt;env-example .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start Devilbox
&lt;/h3&gt;

&lt;p&gt;The time has come, to launch the devilbox!&lt;/p&gt;

&lt;p&gt;To launch the devilbox you need to run the following command on your terminal while you are instead the devilbox directory. &lt;code&gt;docker-compose up&lt;/code&gt; now it will pull all the required containers! The first time you run this it might take a while, depends on your internet connection. But once you have all the images, you should be able to start all the containers in a matter of seconds (~4-5 seconds).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PkmatWoR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/dockercomposeup.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PkmatWoR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/dockercomposeup.png" alt="dockercomposeup" width="800" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;TIP! Run &lt;code&gt;docker-compose up -d&lt;/code&gt; to run the containers in the background detached from your current terminal window.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When all the images are pulled, you should be able to access devilbox localhost URL. By default, The Devilbox is listening to port &lt;code&gt;80&lt;/code&gt; which means you can access it by visiting &lt;a href="http://localhost" rel="noopener noreferrer"&gt;http://localhost&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vsXMvoOe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/devilboxdash.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vsXMvoOe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/devilboxdash.png" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Starting and stopping containers is done via &lt;code&gt;docker-compose&lt;/code&gt;. If you have never worked with it before, have a look at their documentation for &lt;a href="https://docs.docker.com/compose/reference/overview/" rel="noopener noreferrer"&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%2Fkigcjza55hkryqfq81l6.png" alt="img" width="11" height="11"&gt;&lt;/a&gt;, &lt;a href="https://docs.docker.com/compose/reference/up/" rel="noopener noreferrer"&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%2Fkigcjza55hkryqfq81l6.png" alt="img" width="11" height="11"&gt;&lt;/a&gt;, &lt;a href="https://docs.docker.com/compose/reference/stop/" rel="noopener noreferrer"&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%2Fkigcjza55hkryqfq81l6.png" alt="img" width="11" height="11"&gt;&lt;/a&gt;, &lt;a href="https://docs.docker.com/compose/reference/kill/" rel="noopener noreferrer"&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%2Fkigcjza55hkryqfq81l6.png" alt="img" width="11" height="11"&gt;&lt;/a&gt;, &lt;a href="https://docs.docker.com/compose/reference/rm/" rel="noopener noreferrer"&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%2Fkigcjza55hkryqfq81l6.png" alt="img" width="11" height="11"&gt;&lt;/a&gt;, &lt;a href="https://docs.docker.com/compose/reference/logs/" rel="noopener noreferrer"&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%2Fkigcjza55hkryqfq81l6.png" alt="img" width="11" height="11"&gt;&lt;/a&gt;and &lt;a href="https://docs.docker.com/compose/reference/pull/" rel="noopener noreferrer"&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%2Fkigcjza55hkryqfq81l6.png" alt="img" width="11" height="11"&gt;&lt;/a&gt;commands.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;More about starting The Devilbox &lt;a href="https://devilbox.readthedocs.io/en/latest/getting-started/start-the-devilbox.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring Devilbox .ENV FIle
&lt;/h3&gt;

&lt;p&gt;Devilbox is configurable and you can easily switch between dev environments like (PHP,APACHE,MySQL) or (PHP, NGINX,MariaDB). &lt;br&gt;
just open the &lt;code&gt;.env&lt;/code&gt; file with your favourite editor and configure it to match your taste &lt;strong&gt;environment&lt;/strong&gt; . I am using &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;Visual Studio Code&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VwjQ3Of9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/envfile.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VwjQ3Of9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/envfile.png" alt="envfile" width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every configuration is self-explanatory, the most common configuration will be the following where you change the &lt;code&gt;PHP_SERVER&lt;/code&gt; version, &lt;code&gt;HTTPD_SERVER&lt;/code&gt; and &lt;code&gt;MYSQL_SERVER&lt;/code&gt;. As you can see, I am running &lt;code&gt;PHP 7.2&lt;/code&gt;  &lt;code&gt;NGINX stable&lt;/code&gt; and &lt;code&gt;MariaDB 10.3&lt;/code&gt; Go through the .env file to discover other settings. &lt;/p&gt;

&lt;p&gt;Read more about configuring the env file &lt;a href="https://devilbox.readthedocs.io/en/latest/configuration-files/env-file.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Projects Directory
&lt;/h3&gt;

&lt;p&gt;The devilbox's projects directory is located inside the devilbox directory &lt;code&gt;./devilbox/data/www&lt;/code&gt; it should be empty by default. Here is where all your projects will live. &lt;/p&gt;

&lt;p&gt;For each project, you will need to create a folder. &lt;/p&gt;

&lt;p&gt;Read more &lt;a href="https://devilbox.readthedocs.io/en/latest/getting-started/directory-overview.html#project-directory" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Docroot Directory
&lt;/h3&gt;

&lt;p&gt;The docroot directory is a directory within each project directory from which the webserver will serve the files.&lt;/p&gt;

&lt;p&gt;By default this directory must be named &lt;code&gt;htdocs&lt;/code&gt;. This can be changed as well, but is outside the scope of this tutorial. &lt;/p&gt;
&lt;h3&gt;
  
  
  Local domain suffix
&lt;/h3&gt;

&lt;p&gt;The default domain suffix (&lt;code&gt;TLD_SUFFIX&lt;/code&gt; variable in &lt;code&gt;.env&lt;/code&gt; file) is &lt;code&gt;loc&lt;/code&gt;. That means that all your projects will be available under the following address: &lt;code&gt;http://&amp;lt;project-directory&amp;gt;.loc&lt;/code&gt;. This can be changed as well in the &lt;code&gt;.env&lt;/code&gt; file. &lt;code&gt;TLD_SUFFIX&lt;/code&gt;!&lt;/p&gt;
&lt;h3&gt;
  
  
  WordPress Installation
&lt;/h3&gt;

&lt;p&gt;Let us take an example of a WordPress installation from start to the end. &lt;/p&gt;

&lt;p&gt;Open terminal and run the following: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;cd devilbox/data/www&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;mkdir testwp&lt;/code&gt; to create a directory named &lt;strong&gt;testwp&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;cd testwp&lt;/code&gt; enter the dir we just created&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Download WordPress &lt;code&gt;wget http://wordpress.org/latest.tar.gz&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unzip the archive file by running &lt;code&gt;tar -zxvf latest.tar.gz&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;mv wordpress htdocs&lt;/code&gt; (remember docroot directory?)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open &lt;a href="http://testwp.loc/" rel="noopener noreferrer"&gt;http://testwp.loc/&lt;/a&gt; and you should see the following error.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;**testwp.loc**’s server IP address could not be found.&lt;br&gt;
    testwp.loc’s server IP address could not be found.&lt;br&gt;
    DNS_PROBE_FINISHED_NXDOMAIN&lt;br&gt;
&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;This happens because we have not added the local host DNS record. 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you navigate to &lt;a href="http://localhost/vhosts.php" rel="noopener noreferrer"&gt;http://localhost/vhosts.php&lt;/a&gt; you should see something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qDtUJIzW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/hosterror.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qDtUJIzW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/hosterror.png" alt="hosterror" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next step is now to add the record in our hosts file. To do so, run &lt;code&gt;sudo nano /etc/hosts&lt;/code&gt; to edit it with the nano editor and add the following line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`127.0.0.1 testwp.loc`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;hit save.  Navigate again to &lt;a href="http://testwp.loc/" rel="noopener noreferrer"&gt;http://testwp.loc/&lt;/a&gt; and now you should see the WordPress install page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s9akKk2O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/wpinstall.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s9akKk2O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/wpinstall.png" alt="wpinstall" width="800" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next step now, is to create a database for WordPress to use. We can do it by using a terminal or by using &lt;code&gt;phpmyadmin&lt;/code&gt; which comes with the devilbox. To access phpMyAdmin first navigate to &lt;a href="http://localhost/index.php" rel="noopener noreferrer"&gt;http://localhost/index.php&lt;/a&gt; &amp;gt; Tools &amp;gt; phpMyAdmin in case it asks for credentials enter &lt;code&gt;root&lt;/code&gt; as user and leave password field empty.&lt;/p&gt;

&lt;p&gt;No create a new database from the sidebar, I will name it &lt;code&gt;wp_testdb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once done that head back to WordPress Install Page and continue and add the freshly created database. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note! For the Database host instead of &lt;code&gt;localhost&lt;/code&gt; you need to enter &lt;code&gt;mysql&lt;/code&gt; as this is the name of the MySQL server (container)running in the devilbox environment! &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Everything should have run smoothly and you should see the new WordPress site up and running on &lt;a href="http://testwp.loc" rel="noopener noreferrer"&gt;http://testwp.loc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OHk3wNPw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/wplive.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OHk3wNPw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://kociaj.com/content/uploads/2019/06/wplive.png" alt="wplive" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The Devilbox is a free and open source project very very easy to set up and run a PHP, Nginx and MySQL dev environment and a WordPress installation read following this tutorial should take approximately 10 minutes! I have been using Devilbx for about 1 year now, and I am pretty happy with it and find it very convenient when I am working on a project with PHP 7, and I have to switch to a project running on PHP 5.6 it takes me less than 15seconds! ⌛ &lt;/p&gt;

&lt;p&gt;Have you used The Devilbox before? Would you give it a try? &lt;/p&gt;

</description>
      <category>docker</category>
      <category>webdev</category>
      <category>local</category>
      <category>wordpress</category>
    </item>
    <item>
      <title>WordPress Database replacing the easy way</title>
      <dc:creator>Perlat Kociaj</dc:creator>
      <pubDate>Sun, 10 Mar 2019 20:18:50 +0000</pubDate>
      <link>https://dev.to/perlatsp/wordpress-database-replacing-the-easy-way-288k</link>
      <guid>https://dev.to/perlatsp/wordpress-database-replacing-the-easy-way-288k</guid>
      <description>&lt;p&gt;Hi,&lt;br&gt;
I published an NPM package a small cli tool which does the exporting and replacing the URL for a WordPress website piece of cake. You can export and replace within 10 seconds (depending on the size of the database and how fast you type).&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%2Fx7wr75s3fekvgzkj1jpg.gif" 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%2Fx7wr75s3fekvgzkj1jpg.gif" alt="demo" width="1252" height="606"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TLDR;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/@perlatsp/devild" rel="noopener noreferrer"&gt;NPM link&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/perlatsp/devild" rel="noopener noreferrer"&gt;Github link&lt;/a&gt; &lt;/p&gt;



&lt;p&gt;I started this as a project for personal use but decided to make it as an NPM package and publicly accessible.  We all know the ritual for WordPress development.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Develop local using Docker containers &lt;/li&gt;
&lt;li&gt;Use git commit, git push (or FTP upload for old school hardcore people) to deploy &lt;/li&gt;
&lt;li&gt;open phpmyadmin, find the database, export the database&lt;/li&gt;
&lt;li&gt;find the file in the downloads folder (find which one is the latest from &lt;code&gt;database (2).sql&lt;/code&gt; or &lt;code&gt;database (3).sql&lt;/code&gt; or &lt;code&gt;database (5).sql&lt;/code&gt; because you deleted (4)&lt;/li&gt;
&lt;li&gt;replace the local URL with the staging/production URL you can do it by:

&lt;ul&gt;
&lt;li&gt;using any text editor to search/replace the URL or&lt;/li&gt;
&lt;li&gt;using a plugin to import and replace URL in the database

&lt;ul&gt;
&lt;li&gt;Install the plugin&lt;/li&gt;
&lt;li&gt;Configure the plugin&lt;/li&gt;
&lt;li&gt;Run the search/replace and wait to finish&lt;/li&gt;
&lt;li&gt;Done
Or do the following while you are in your project directory: &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;run &lt;code&gt;devild db:export&lt;/code&gt; and follow the instructions to export your database in your current directory&lt;/li&gt;
&lt;li&gt;run &lt;code&gt;devild db:replace&lt;/code&gt; and follow the instructions to replace the URL and create another file to keep the original one.&lt;/li&gt;
&lt;li&gt;done  ( ~10 seconds ⏳ )&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This package is available at &lt;a href="https://www.npmjs.com/package/@perlatsp/devild" rel="noopener noreferrer"&gt;NPM Registry&lt;/a&gt; where you can install it by running &lt;code&gt;yarn global add @perlatsp/devild&lt;/code&gt; or &lt;code&gt;npm i -g @perlatsp/devild&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Feedback and PR are more than welcome. :D &lt;br&gt;
&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/perlatsp" rel="noopener noreferrer"&gt;
        perlatsp
      &lt;/a&gt; / &lt;a href="https://github.com/perlatsp/devild" rel="noopener noreferrer"&gt;
        devild
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;😈Devild - Wordpress DB export &amp;amp; replace the easy way&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Database export and search replace for sql files&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/perlatsp/devild./demo.gif"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HymgLUO9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://github.com/perlatsp/devild./demo.gif" width="650"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;How to use&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npm i -g @perlatsp/devild&lt;/code&gt; to install it as a global package.&lt;/li&gt;
&lt;li&gt;You can now access it by running &lt;code&gt;devild &amp;lt;command&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NOTE!&lt;/strong&gt; If you are using devilbox / docker containers you will need to do the above inside the container.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Available commands&lt;/h3&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;devild&lt;/code&gt; or &lt;code&gt;devild help&lt;/code&gt; - Will display help message with available commands&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;devild db:export&lt;/code&gt;        - Will ask credentials to export database&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;devild db:replace&lt;/code&gt;       - Will ask questions to replace url in the exported &lt;code&gt;sql&lt;/code&gt; file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;devild install&lt;/code&gt;          - Will create sample config file to create projects repositories (name,type,url)-&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;devild project:start&lt;/code&gt;    - Will ask questions to create a new project based upon set configurations&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;devild project:add&lt;/code&gt;      - Will ask questions to add a new project to your configuration file&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;TODO&lt;/h3&gt;

&lt;/div&gt;
&lt;ul class="contains-task-list"&gt;
&lt;li class="task-list-item"&gt;
 Search Replace in current dir&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Create Project (WP or…&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/perlatsp/devild" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>wordpress</category>
      <category>npm</category>
      <category>node</category>
      <category>showdev</category>
    </item>
    <item>
      <title>VueJS questions </title>
      <dc:creator>Perlat Kociaj</dc:creator>
      <pubDate>Mon, 04 Mar 2019 15:08:52 +0000</pubDate>
      <link>https://dev.to/perlatsp/vuejs-questions--k1l</link>
      <guid>https://dev.to/perlatsp/vuejs-questions--k1l</guid>
      <description>&lt;p&gt;Hey all, &lt;br&gt;
i created &lt;a href="https://vuejsquestions.com?ref=devto"&gt;VueJS questions &lt;/a&gt; for common VueJS questions. &lt;br&gt;
It is a side project while i started learning UIKIT frontend framework and improving my skills on web performance and seo. &lt;/p&gt;

&lt;p&gt;At the moment it is fetching the questions from stackoverflow. Any feedback will be appreciated negative or positive. &lt;/p&gt;

</description>
      <category>vue</category>
      <category>uikit</category>
      <category>wordpress</category>
      <category>sideprojects</category>
    </item>
  </channel>
</rss>
