<?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: Saad Abbasi</title>
    <description>The latest articles on DEV Community by Saad Abbasi (@saadabbasi).</description>
    <link>https://dev.to/saadabbasi</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%2F493508%2F3401c706-bb64-46d8-b007-69c91a85bd74.jpeg</url>
      <title>DEV Community: Saad Abbasi</title>
      <link>https://dev.to/saadabbasi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saadabbasi"/>
    <language>en</language>
    <item>
      <title>How to Install node.js app on VPS shared hosting?</title>
      <dc:creator>Saad Abbasi</dc:creator>
      <pubDate>Wed, 05 May 2021 19:13:59 +0000</pubDate>
      <link>https://dev.to/saadabbasi/how-to-install-node-js-app-on-vps-shared-hosting-lhm</link>
      <guid>https://dev.to/saadabbasi/how-to-install-node-js-app-on-vps-shared-hosting-lhm</guid>
      <description>&lt;p&gt;In this article, I will show you how to install &lt;code&gt;node.js&lt;/code&gt; on &lt;strong&gt;shared hosting&lt;/strong&gt;&lt;br&gt;
if you just purchased new shared hosting and there is not node.js installed. &lt;br&gt;
Don't worry in this step-by-step guide you will learn to install &lt;code&gt;node.js&lt;/code&gt; with &lt;code&gt;SSH&lt;/code&gt; without &lt;code&gt;sudo&lt;/code&gt; or &lt;code&gt;root&lt;/code&gt; access.&lt;br&gt;
I am a Windows user, for connecting to the server via &lt;code&gt;SSH&lt;/code&gt; i will use putty software that's free and easy to use.&lt;br&gt;
I assume that you have already installed &lt;code&gt;putty&lt;/code&gt; if not just google you will see lots of tutorials on How to install putty on windows. &lt;/p&gt;
&lt;h1&gt;
  
  
  How to use putty?
&lt;/h1&gt;

&lt;p&gt;search putty in your window's search bar and click on &lt;code&gt;putty&lt;/code&gt; to execute. &lt;/p&gt;
&lt;h3&gt;
  
  
  You will see the following screen
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2g5nh6cyizpqbxggkqd4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2g5nh6cyizpqbxggkqd4.png" alt="How to Install node.js app on VPS shared hosting?"&gt;&lt;/a&gt;&lt;br&gt;
Enter the following values in putty for connecting to the server&lt;br&gt;
1.Enter Your Server/cPanel IP Address in * hostname (or IP address field*&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;By Default &lt;code&gt;Port 22&lt;/code&gt; is used if you have not  default case you &lt;em&gt;You Can Find Your Port Number in Server Details&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Click on &lt;code&gt;Open Button&lt;/code&gt;
if everything is correct you will see a black screen asking for
&lt;code&gt;Login as&lt;/code&gt; enter your username here &lt;em&gt;make sure to enter correct user name&lt;/em&gt;
&lt;code&gt;Enter password&lt;/code&gt; &lt;em&gt;Enter the correct password for username. *password will not be visible just type your password and hit enter&lt;/em&gt; 
If You Enter the Correct cPanel Username and Password then you will see the next screen with your username. &lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  Now you are connected to Server successfully let's install node.js on shared hosting
&lt;/h4&gt;

&lt;p&gt;Run the following command to download node.js you can download any version of &lt;code&gt;node.js&lt;/code&gt; by changing the to a specific version. i am downloading &lt;code&gt;v8.10.0&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;wget https://nodejs.org/dist/v8.10.0/node-v8.10.0-linux-x64.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Now we have downloaded &lt;code&gt;node.js&lt;/code&gt; on our server let's  Extract Node JS Files by using the following command
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tar xvzf node-v8.10.0-linux-x64.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Let's rename the folder to &lt;code&gt;nodejs&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv node-v8.10.0-linux-x64 nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Let's install &lt;code&gt;Node.js&lt;/code&gt; and &lt;code&gt;npm&lt;/code&gt; type the following &lt;code&gt;commands&lt;/code&gt; one by one
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;mkdir ~/bin&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cp nodejs/bin/node ~/bin&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;cd ~/bin&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npm&lt;/code&gt;
#That's it. Node.js and npm installed on your hosting you can verify that by running &lt;code&gt;node -v&lt;/code&gt; if yo see &lt;code&gt;node.js&lt;/code&gt; version it's mean you have successfully installed node.js on shared/vps hosting.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thanks for reading :-) can you write your thoughts? and help me to improve my content by your valued suggestions? or if you have any querry please comment bellow.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__493508"&gt;
    &lt;a href="/saadabbasi" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F493508%2F3401c706-bb64-46d8-b007-69c91a85bd74.jpeg" alt="saadabbasi image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/saadabbasi"&gt;Saad Abbasi&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/saadabbasi"&gt;Hello 👋🏽
I am **Saad Abbasi**. A MEAN stack Developer. &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>deploy</category>
      <category>node</category>
      <category>host</category>
      <category>ssh</category>
    </item>
    <item>
      <title>Do you want to run Angular App on the Node.js server? </title>
      <dc:creator>Saad Abbasi</dc:creator>
      <pubDate>Tue, 04 May 2021 06:25:35 +0000</pubDate>
      <link>https://dev.to/saadabbasi/do-you-want-to-run-angular-app-on-the-node-js-server-2a62</link>
      <guid>https://dev.to/saadabbasi/do-you-want-to-run-angular-app-on-the-node-js-server-2a62</guid>
      <description>&lt;p&gt;Do you want to serve your Angular app on the node.js server?&lt;br&gt;
I assume that you already have an angular app now you want to render it with node.js. in this dev blog, I will explain how you can achieve this in a very easy and secure way by using view engines in node.js.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F25m3fxrp0qilku7zv9wf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F25m3fxrp0qilku7zv9wf.png" alt="Node.js"&gt;&lt;/a&gt;&lt;br&gt;
also, I will explain how you can render modify your endpoints to work with the server-side, you might using service to hit the specific backend by going on the specific route. e.g signup-route. &lt;br&gt;
let's get started. &lt;br&gt;
Table of content.&lt;/p&gt;

&lt;h5&gt;
  
  
  1)What is angular
&lt;/h5&gt;

&lt;h5&gt;
  
  
  2)What is PUG (in this tutorial I will use pug)?
&lt;/h5&gt;

&lt;h5&gt;
  
  
  3)How to render Angular application with node.js backend
&lt;/h5&gt;

&lt;h2&gt;
  
  
  What is Angular?
&lt;/h2&gt;

&lt;p&gt;Angular is a TypeScript-based open-source web application framework led by the Angular Team at Google and by a community of individuals and corporations.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is PUG?
&lt;/h2&gt;

&lt;p&gt;PUG is a &lt;em&gt;robust&lt;/em&gt;, &lt;em&gt;elegant&lt;/em&gt;, a &lt;em&gt;feature-rich&lt;/em&gt; template engine for Node.js&lt;/p&gt;

&lt;h2&gt;
  
  
  How to render Angular application on the node.js server?
&lt;/h2&gt;

&lt;p&gt;As we know that Angular is SPA(Single Page Application) we can render its content with node.js backend.&lt;br&gt;
Luckily node.js provide template engines to run templates on the server-side. we can use any template engine like &lt;em&gt;jade, pug, ejs&lt;/em&gt; to run the angular application but in this dev blog, I will use pug.&lt;br&gt;
these are the steps to render angular applications with pug template engine. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;production build an angular application by running the following command with &lt;em&gt;angular cli&lt;/em&gt;
&lt;code&gt;ng build --prod&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;after successful build you will see build files by default in &lt;code&gt;dist&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;Install template engine by running the following command
&lt;code&gt;npm install --save pug&lt;/code&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9y2lq3571nim1bjm4g5.png" alt="install pug "&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7egxm28bih9bgesipkpw.png" alt="pug template node.js setup"&gt;
```
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;const app = express();&lt;br&gt;
app.use(express.static('../dist/interior'))//set the static path &lt;br&gt;
app.set('view engine', 'pug');&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5. `View-engine` setup is completed now it's time to render `Angular` app  add the following code after view engine 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;app.get('/', (req, res) =&amp;gt; {&lt;br&gt;
    res.sendFile('index.html',{root:__dirname})&lt;br&gt;
});&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6. Now when you run your node.js app you will see the angular app in action. Note: if you want to change the route you can change the above code like this to render angular app on a specific route e.g when the user hits `/angular`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;app.get('/angular', (req, res) =&amp;gt; {&lt;br&gt;
    res.sendFile('index.html',{root:__dirname})&lt;br&gt;
});&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;##Complete code will look like this 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;const express = require('express');&lt;br&gt;
const path = require('path')&lt;br&gt;
const port = 8080;&lt;br&gt;
const app = express();&lt;/p&gt;

&lt;p&gt;app.use(express.static('../dist/angular-directory'))&lt;br&gt;
app.set('view engine', 'pug');&lt;/p&gt;

&lt;p&gt;app.get('/', (req, res) =&amp;gt; {&lt;br&gt;
    res.sendFile('index.html',{root:__dirname})&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;app.listen(port, () =&amp;gt; {&lt;br&gt;
    console.log("Server is listening on port "+port);&lt;br&gt;
});&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;###### run `node app.js` and visit `localhost:8080` you will see your angular app running on node.js (express server) 
That's all for this blog I hope this will help you, consider writing your thought and feedback, so I can improve my writing and help people in a better way.
Best Regards
&lt;div class="ltag__user ltag__user__id__493508"&gt;
    &lt;a href="/saadabbasi" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F493508%2F3401c706-bb64-46d8-b007-69c91a85bd74.jpeg" alt="saadabbasi image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/saadabbasi"&gt;Saad Abbasi&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/saadabbasi"&gt;Hello 👋🏽
I am **Saad Abbasi**. A MEAN stack Developer. &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

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

&lt;/div&gt;

</description>
      <category>angular</category>
      <category>node</category>
      <category>static</category>
      <category>pug</category>
    </item>
    <item>
      <title>How to use securely API's in node.js? </title>
      <dc:creator>Saad Abbasi</dc:creator>
      <pubDate>Thu, 29 Apr 2021 18:48:46 +0000</pubDate>
      <link>https://dev.to/saadabbasi/how-to-use-securely-api-s-in-node-js-4f6d</link>
      <guid>https://dev.to/saadabbasi/how-to-use-securely-api-s-in-node-js-4f6d</guid>
      <description>&lt;p&gt;Hi everyone &lt;br&gt;
in this blog, I am going to share how you can use your &lt;strong&gt;APi's  PORTS, Hash Secrets&lt;/strong&gt; in node.js by using environment variables.&lt;/p&gt;

&lt;p&gt;1) Install &lt;em&gt;dotenv&lt;/em&gt; by running this command in &lt;strong&gt;node.js&lt;/strong&gt; terminal npm install dotenv &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KusATHsN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ofxf0d20qzvilr5zq0bt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KusATHsN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ofxf0d20qzvilr5zq0bt.png" alt="Node.js environment variables "&gt;&lt;/a&gt;&lt;br&gt;
2) Creat new &lt;em&gt;.env&lt;/em&gt; file name should b .env you will see an gear icon&lt;br&gt;&lt;br&gt;
3) define secret values and variables like the bellow snippet. follow exact same patter don't use "Quotes for strings"&lt;br&gt;
  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c7GoMBLk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5yuaopemts9x66y4mb1n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c7GoMBLk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5yuaopemts9x66y4mb1n.png" alt="node.js env file"&gt;&lt;/a&gt;&lt;br&gt;
4) require it in the root of the application. before calling any route it's good practice to use it ASAP. also call config for configuration of.env variables &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u6m3FhvI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aplnqvq7ag4hne8wgtk1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u6m3FhvI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aplnqvq7ag4hne8wgtk1.png" alt="node.js require and config .env "&gt;&lt;/a&gt;&lt;br&gt;
5) Finally use it anywhere in the application by using &lt;em&gt;process.env.variableName&lt;/em&gt; see example bellow &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8Kz4IiKH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phlsckheunujolaaavi1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Kz4IiKH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phlsckheunujolaaavi1.png" alt="node.js environment variable dotenv process.env"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all for using .env in node.js. this is my first post on dev.to . please leave your feedback about this blog. (this is my first blog/tutorial post ). &lt;/p&gt;

&lt;p&gt;Thanks &lt;br&gt;
Saad Abbasi (MEAN stack Dev)&lt;/p&gt;

</description>
      <category>node</category>
      <category>envvariable</category>
      <category>express</category>
      <category>dotenv</category>
    </item>
  </channel>
</rss>
