<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Javascript &#8211; Otricks.com</title>
	<atom:link href="https://otricks.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>https://otricks.com</link>
	<description>It&#039;s the big &#039;O&#039; in technology</description>
	<lastBuildDate>Wed, 29 Dec 2021 12:44:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>Create front-end app for space-XYZ cargo booking system.</title>
		<link>https://otricks.com/create-front-end-app-for-space-xyz-cargo-booking-system/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Wed, 29 Dec 2021 12:44:48 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Nodejs]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2378</guid>

					<description><![CDATA[<p>This is multi-part post and this is 2 or 3 part. Our base design would be like space-x website with header, background image and some&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/create-front-end-app-for-space-xyz-cargo-booking-system/">Create front-end app for space-XYZ cargo booking system.</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This is multi-part post and this is 2 or 3 part.</p>



<p>Our base design would be like space-x website with header, background image and some text, we will create a full functional strapi server from where all data comes eventually. For now we will create dummy text and dummy image placeholder, later we will integrate with API from strapi.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="561" src="https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-20-at-11.27.23-PM-1024x561.png" alt="" class="wp-image-2388" srcset="https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-20-at-11.27.23-PM-1024x561.png 1024w, https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-20-at-11.27.23-PM-300x164.png 300w, https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-20-at-11.27.23-PM-768x421.png 768w, https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-20-at-11.27.23-PM-1536x842.png 1536w, https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-20-at-11.27.23-PM-2048x1123.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Create new empty folder and name it <strong><em>space-xyz</em></strong> then cd into it, open terminal window I will be using <a rel="noreferrer noopener" href="https://iterm2.com/" target="_blank">iTerm2</a> for my terminal window and run below command it will generate new angular project.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-admin-page"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="13" data-lines="5" data-showlines="true" data-copy="true">npx -p  @angular/cli@10.2.1 ng new space-xyz </pre></div>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="13" data-lines="20" data-showlines="true" data-copy="false">? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? SCSS   [ https://sass-lang.com/documentation/syntax#scss                ]
CREATE space-xyz/README.md (1017 bytes)
CREATE space-xyz/.editorconfig (274 bytes)
CREATE space-xyz/.gitignore (631 bytes)
CREATE space-xyz/angular.json (3678 bytes)
CREATE space-xyz/package.json (1252 bytes)
CREATE space-xyz/tsconfig.json (458 bytes)
CREATE space-xyz/tslint.json (3185 bytes)
CREATE space-xyz/.browserslistrc (853 bytes)
CREATE space-xyz/karma.conf.js (1021 bytes)
CREATE space-xyz/tsconfig.app.json (287 bytes)
CREATE space-xyz/tsconfig.spec.json (333 bytes)
CREATE space-xyz/src/favicon.ico (948 bytes)
CREATE space-xyz/src/index.html (294 bytes)
CREATE space-xyz/src/main.ts (372 bytes)
CREATE space-xyz/src/polyfills.ts (2830 bytes)
CREATE space-xyz/src/styles.scss (80 bytes)
CREATE space-xyz/src/test.ts (753 bytes)
CREATE space-xyz/src/assets/.gitkeep (0 bytes)
CREATE space-xyz/src/environments/environment.prod.ts (51 bytes)
CREATE space-xyz/src/environments/environment.ts (662 bytes)
CREATE space-xyz/src/app/app-routing.module.ts (245 bytes)
CREATE space-xyz/src/app/app.module.ts (393 bytes)
CREATE space-xyz/src/app/app.component.scss (0 bytes)
CREATE space-xyz/src/app/app.component.html (25757 bytes)
CREATE space-xyz/src/app/app.component.spec.ts (1066 bytes)
CREATE space-xyz/src/app/app.component.ts (214 bytes)
CREATE space-xyz/e2e/protractor.conf.js (869 bytes)
CREATE space-xyz/e2e/tsconfig.json (294 bytes)
CREATE space-xyz/e2e/src/app.e2e-spec.ts (642 bytes)
CREATE space-xyz/e2e/src/app.po.ts (301 bytes)
&#x2714; Packages installed successfully.
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: 	git config --global init.defaultBranch &lt;name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m &lt;name>
    Successfully initialized git.</pre></div>



<p>Open frontend project in your favorite code editor, I will be using visual studio code (vscode) its super fast and build on node stack too.</p>



<p>We will generate header component user angular CLI command, It will be very simple header to hold our navigation and logo for our application.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-admin-page"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="13" data-lines="5" data-showlines="true" data-copy="true">npx ng generate component header </pre></div>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="10" data-showlines="true" data-copy="false">? Would you like to share anonymous usage data about this project with the Angular Team at
Google under Google’s Privacy Policy at https://policies.google.com/privacy? For more
details and how to change this setting, see http://angular.io/analytics. Yes

Thank you for sharing anonymous usage data. Would you change your mind, the following
command will disable this feature entirely:

    ng analytics project off

CREATE src/app/header/header.component.scss (0 bytes)
CREATE src/app/header/header.component.html (21 bytes)
CREATE src/app/header/header.component.spec.ts (626 bytes)
CREATE src/app/header/header.component.ts (276 bytes)
UPDATE src/app/app.module.ts (475 bytes)</pre></div>



<p>Insider header component &#8220;<strong><em>header/header.component.html</em></strong>&#8221; </p>



<p>We will use our server to provide all the data for now we will just use as place holder.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-admin-page"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="html" data-theme="monokai" data-fontsize="13" data-lines="Infinity" data-showlines="true" data-copy="true">&lt;div class="header-holder">
  &lt;div class="logo">
    &lt;h1>Space-XYZ&lt;/h1>
  &lt;/div>
  &lt;div class="menu">
    &lt;ul>
      &lt;li>
        &lt;a routerLink="/first-component" routerLinkActive="active">link 1&lt;/a>
      &lt;/li>
      &lt;li>
        &lt;a routerLink="/first-component" routerLinkActive="active">link 2&lt;/a>
      &lt;/li>
      &lt;li>
        &lt;a routerLink="/first-component" routerLinkActive="active">link 3&lt;/a>
      &lt;/li>
      &lt;li>
        &lt;a routerLink="/first-component" routerLinkActive="active">link 4&lt;/a>
      &lt;/li>
      &lt;li>
        &lt;a routerLink="/first-component" routerLinkActive="active">link 5&lt;/a>
      &lt;/li>
    &lt;/ul>
  &lt;/div>
&lt;/div>
</pre></div>



<p>Let&#8217;s create body component to hold some text and other data.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">npx ng generate component body </pre></div>



<p>Insider body component &#8220;<strong><em>body/body.component.html</em></strong>&#8220;</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="html" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">&lt;div class="body-holder">
  &lt;h1>Some Name comes form server&lt;/h1>
  &lt;p>Some text comes from server&lt;/p>
  &lt;a href="">Book it now&lt;/a>
&lt;/div></pre></div>



<p>Insider body component &#8220;<strong><em>body/body.component.scss</em></strong>&#8220;</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="scss" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">// body/body.component.scss

.body-holder {
  display: flex;
  align-items: center;
  flex-direction: column;
  margin-top: 15%;

  h1 {
    font-size: 60px;
    text-transform: uppercase;
    color: #fff;
  }

  p {
    color: #fff;
    text-transform: uppercase;
  }
  a {
    text-decoration: none;
    background: green;
    border: 1px solid #037203;
    color: #fff;
    padding: 20px;
    font-size: 16px;
    text-transform: uppercase;
  }
}
</pre></div>



<p>Update routing &#8220;<strong><em>app-routing.module.ts</em></strong>&#8221; file with below code.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="typescript" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">// app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { BodyComponent } from './body/body.component';

const routes: Routes = [
  {
    path: ':id',
    component: BodyComponent,
  },
  {
    path: '',
    component: BodyComponent,
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {}
</pre></div>



<p>Update app component  &#8220;<strong><em>app.component.html</em></strong>&#8221; file  and &#8220;<strong><em>app.component.ts&#8221; </em></strong>with below code. Later we will get background image from API response, for now we are hardcoding <strong><em>backgroundImage</em></strong> path </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="html" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">&lt;!--app.component.html-->

&lt;div
  class="body"
  [ngStyle]="{
    background:
      'url(' + backgroundImage + ') #000 no-repeat center bottom / contain'
  }"
>
  &lt;div class="container">
    &lt;app-header>&lt;/app-header>
    &lt;router-outlet>&lt;/router-outlet>
  &lt;/div>
&lt;/div>
</pre></div>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="typescript" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">// app.component.ts

import { Component } from '@angular/core';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent {
  title = 'space-xyz';
  backgroundImage = null;

  constructor() {
    this.backgroundImage = '../../assets/f9_feature.webp';
  }
}
</pre></div>



<p>And last update &#8220;<strong><em>app.module.ts</em></strong>&#8221; to reflect those changes.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="typescript" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">//app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { BodyComponent } from './body/body.component';

@NgModule({
  declarations: [AppComponent, HeaderComponent, BodyComponent],
  imports: [BrowserModule, AppRoutingModule],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}</pre></div>



<p>Finally run angular application to view our frontend app. You will be able to see something like below screen shot. </p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="730" src="https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-28-at-9.48.35-PM-1024x730.png" alt="" class="wp-image-2392" srcset="https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-28-at-9.48.35-PM-1024x730.png 1024w, https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-28-at-9.48.35-PM-300x214.png 300w, https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-28-at-9.48.35-PM-768x547.png 768w, https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-28-at-9.48.35-PM-1536x1095.png 1536w, https://otricks.com/wp-content/uploads/2021/12/Screen-Shot-2021-12-28-at-9.48.35-PM-2048x1460.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>For some reason if you miss any step you can check <a rel="noreferrer noopener" href="https://github.com/anjum121/space-xyz/tree/master/fontend" target="_blank">https://github.com/anjum121/space-xyz/tree/master/fontend</a> link for final code.</p>



<p>Next step is to create Strapi system, let&#8217;s go to backend part. 🙂 </p>
<p>The post <a rel="nofollow" href="https://otricks.com/create-front-end-app-for-space-xyz-cargo-booking-system/">Create front-end app for space-XYZ cargo booking system.</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to use webSocket/Socket.io inside Strapi content management system.</title>
		<link>https://otricks.com/how-to-use-websocket-socket-io-inside-strapi-content-management-system/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Wed, 29 Dec 2021 12:39:28 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Nodejs]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2369</guid>

					<description><![CDATA[<p>What is WebSocket? WebSocket is very useful pice of technology to communicate seamlessly from server to client, unlike HTTP it use full-duplex data transmission meaning, data&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-use-websocket-socket-io-inside-strapi-content-management-system/">How to use webSocket/Socket.io inside Strapi content management system.</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading"><strong>What is WebSocket?</strong></h3>



<p>WebSocket is very useful pice of technology  to communicate seamlessly from server to client, unlike HTTP it use full-duplex data transmission meaning,  data can be transmitted in both directions on a signal carrier at the same time. To interact with webSocket we can use <a rel="noreferrer noopener" href="http://socket.io" target="_blank">socket.io</a> library which hides most of the stuff and provide clean API.</p>



<h3 class="wp-block-heading"><strong>What is strapi? </strong></h3>



<p>It&#8217;s headless content management system, if this headless makes no sense then think like <a href="https://wordpress.org/" target="_blank" rel="noreferrer noopener">wordpress</a> or <a href="https://www.joomla.org/">Joomla</a>  content management systems (cms) they comes with themes which user can install and see something in action, however in headless CMS there are no theme system, user needs to create their own theme for website or they can consume data on mobile apps.</p>



<p><a rel="noreferrer noopener" href="https://strapi.io/" target="_blank">Strapi</a> is open source nodejs based system, its based on <a rel="noreferrer noopener" href="https://koajs.com/" target="_blank">Koa.js.com</a> or follows same style of coding. Its comes with Rest API as well as <a rel="noreferrer noopener" href="https://graphql.org/" target="_blank">graphql</a> support too.</p>



<p>I don&#8217;t want to create chat-room example for this guide. May be We can create to booking system to send payload to Mars using <a rel="noreferrer noopener" href="https://www.spacex.com/vehicles/dragon/" target="_blank">space-x</a> shuttle service, where user can book a cargo in the space-x rocket once space is allocated from space-x&#8217;s team, the user will get notification via WebSocket about cargo space. </p>



<p>It&#8217;s going to be very long post, hence I will create it in multiple steps. I will be pushing code to Github in every step so do checkout all the steps of the code.</p>



<h3 class="wp-block-heading">I will try to implement following </h3>



<ul class="wp-block-list"><li>Create Angular application for frontend system (FE).</li><li>Create user login (FE)</li><li>Create protected route (FE)</li><li>Create Strapi application for backend system (BE).</li><li>Create sample API (BE).</li><li>Create dummy user (BE).</li><li>Start communication from Angular application to Strapi application.</li><li>Identify user and based on user send socket messages.</li></ul>



<p>Lets start building our frontend system first, I will call our fictional cargo booking company. space-XYZ .</p>



<p>Please click her to checkout frontend system.</p>



<p></p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-use-websocket-socket-io-inside-strapi-content-management-system/">How to use webSocket/Socket.io inside Strapi content management system.</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to implement SSL Pinning in Ionic 5?</title>
		<link>https://otricks.com/how-to-implement-ssl-pinning-in-ionic-5-or-html5-app/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Thu, 26 Mar 2020 20:08:04 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mobile Apps]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2135</guid>

					<description><![CDATA[<p>When we develop ionic or HTML5 hybrid application often we ignore some of the goofy security stuff, however, when a client wants to do security&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-implement-ssl-pinning-in-ionic-5-or-html5-app/">How to implement SSL Pinning in Ionic 5?</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When we develop ionic or HTML5 hybrid application often we ignore some of the goofy security stuff, however, when a client wants to do security testing checkup, we need to implement many things which we really don&#8217;t care at the time of development, one of such thing is <a rel="noreferrer noopener" aria-label="SSL Pinning (opens in a new tab)" href="https://en.wikipedia.org/wiki/HTTP_Public_Key_Pinning" target="_blank">SSL Pinning</a> </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>The pinning is an optional mechanism that can be used to improve the security of a service or site that relies on SSL Certificates. Pinning allows you to specify a cryptographic identity that should be accepted by users visiting your website </p></blockquote>



<p>It&#8217;s a two-part process, first, we need to get a certificate from our API server where we host our backend services. second,  we will need to implement SSL Pinning in the ionic app. Without further ado, let&#8217;s start the first part: </p>



<h2 class="wp-block-heading">Step 1: Get the SSL Certificate from API Server.</h2>



<p>Let&#8217;s pretend that our API server is <a rel="noreferrer noopener" aria-label="otricks.com (opens in a new tab)" href="https://otricks.com/" target="_blank">otricks.com</a> we can get an SSL certificate for the same, I will show you a very easy way to get it via <a rel="noreferrer noopener" aria-label="Firefox (opens in a new tab)" href="https://www.mozilla.org/en-US/firefox/new/" target="_blank">Firefox</a> browser.</p>



<p>Go to otricks.com or your API endpoint with https </p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="474" src="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.03-1024x474.png" alt="" class="wp-image-2138" srcset="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.03-1024x474.png 1024w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.03-300x139.png 300w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.03-768x355.png 768w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.03-1536x711.png 1536w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.03.png 1906w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large border: 1px solid #ddd"><img loading="lazy" decoding="async" width="1024" height="597" src="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.28-1024x597.png" alt="" class="wp-image-2139" srcset="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.28-1024x597.png 1024w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.28-300x175.png 300w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.28-768x448.png 768w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.28-1536x896.png 1536w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.28.png 1914w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="743" src="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.42-1024x743.png" alt="" class="wp-image-2140" srcset="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.42-1024x743.png 1024w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.42-300x218.png 300w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.42-768x557.png 768w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.42-1536x1114.png 1536w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-19.20.42-2048x1485.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>When you click on PEM(cert), it will download <strong><em>otricks-com.pem</em></strong> file which you can convert it to <strong><em>filename.cer</em></strong>  file extension. You need to have <a rel="noreferrer noopener" aria-label="OpenSSL (opens in a new tab)" href="https://www.openssl.org/" target="_blank">OpenSSL</a> tool install in your machine, I have it already in my Macbook Pro. You can google it and install it.</p>



<p>Open a terminal window and run below command which will convert <code>.pem</code> a file to <code>.cer</code> file, change &#8220;nameOfPemFile.pem &#8221; with your file and adjust the path accordingly. Once you run below command it will convert your <strong><em><code>pem</code></em></strong> file to <strong><em><code>cer</code></em></strong> file which we need for our next step.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-admin-page"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">openssl x509 -inform PEM -in /Users/anjum/Downloads/nameOfPemFile.pem -outform DER -out /Users/anjum/Downloads/certificate.cer
</pre></div>



<h2 class="wp-block-heading">Step 2: Create a new Ionic 5 project.</h2>



<p>Let&#8217;s create a new empty project with the Ionic CLI tool</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-admin-page"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="powershell" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">ionic start sslpinning tabs
</pre></div>



<p>Open the project and edit the angular.json file add certificates block something like below. check app =&gt; architect =&gt; build =&gt; assets section.  This way Angular will copy our <code>certificates</code> inside <code>www</code> folder of ionic when we build project</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-admin-page"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">{
    "glob": "**/*",
    "input": "src/certificates",
    "output": "certificates"
},</pre></div>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="10" data-showlines="true" data-copy="false">{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "defaultProject": "app",
  "newProjectRoot": "projects",
  "projects": {
    "app": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "www",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "assets": [
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "assets"
              },
              {
                "glob": "**/*",
                "input": "src/certificates",
                "output": "certificates"
              },
              {
                "glob": "**/*.svg",
                "input": "node_modules/ionicons/dist/ionicons/svg",
                "output": "./svg"
              }
            ],
            "styles": [
              {
                "input": "src/theme/variables.scss"
              },
              {
                "input": "src/global.scss"
              }
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                }
              ]
            },
            "ci": {
              "progress": false
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "app:build:production"
            },
            "ci": {
              "progress": false
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "app:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "styles": [],
            "scripts": [],
            "assets": [
              {
                "glob": "favicon.ico",
                "input": "src/",
                "output": "/"
              },
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "/assets"
              }
            ]
          },
          "configurations": {
            "ci": {
              "progress": false,
              "watch": false
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": ["**/node_modules/**"]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "app:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "app:serve:production"
            },
            "ci": {
              "devServerTarget": "app:serve:ci"
            }
          }
        },
        "ionic-cordova-build": {
          "builder": "@ionic/angular-toolkit:cordova-build",
          "options": {
            "browserTarget": "app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "app:build:production"
            }
          }
        },
        "ionic-cordova-serve": {
          "builder": "@ionic/angular-toolkit:cordova-serve",
          "options": {
            "cordovaBuildTarget": "app:ionic-cordova-build",
            "devServerTarget": "app:serve"
          },
          "configurations": {
            "production": {
              "cordovaBuildTarget": "app:ionic-cordova-build:production",
              "devServerTarget": "app:serve:production"
            }
          }
        }
      }
    }
  },
  "cli": {
    "defaultCollection": "@ionic/angular-toolkit"
  },
  "schematics": {
    "@ionic/angular-toolkit:component": {
      "styleext": "scss"
    },
    "@ionic/angular-toolkit:page": {
      "styleext": "scss"
    }
  }
}
</pre></div>



<p>Let&#8217;s make <code>certificates</code> folder inside <code>src</code> folder and copy your .cer file inside it. please check the screenshot below for the folder structure.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="485" height="1024" src="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-23.04.06-485x1024.png" alt="" class="wp-image-2157" srcset="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-23.04.06-485x1024.png 485w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-23.04.06-142x300.png 142w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-23.04.06.png 648w" sizes="auto, (max-width: 485px) 100vw, 485px" /></figure>



<p>Now open the terminal and run <code>ionic cordova platform add android</code> to add an android platform. It will generate all related files and folders for android. Open the file <code>config.xml</code> and add below code inside the platform block.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-admin-page"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="xml" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">&lt;platform name="android">
     &lt;!-- other tags will be here  -->
    &lt;resource-file src="src/certificates/certificate.cer" target="src/certificates/certificate.cer" />
&lt;/platform></pre></div>



<p>Next, we need to include the Cordova plugin for SSL Pinning, for that we will use <a rel="noreferrer noopener" href="https://github.com/silkimen/cordova-plugin-advanced-http" target="_blank">https://github.com/silkimen/cordova-plugin-advanced-http</a> plugin which is great.  Run below commands in the terminal to install the plugin in the project and we will also need ionic native too.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20" class="dashicon dashicons-admin-page"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">ionic cordova plugin add cordova-plugin-advanced-http

npm install @ionic-native/http
</pre></div>



<p>Once done open <code>app.component.ts</code> file and add code inside <code>initializeApp()</code> function check below file </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="typescript" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">import { Component } from '@angular/core';

import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

 
import { HTTP } from '@ionic-native/http/ngx'; //&lt;=== Import this 

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.scss']
})
export class AppComponent {
  constructor(
    private platform: Platform,
    private splashScreen: SplashScreen,
    private statusBar: StatusBar,
    private httpSSL: HTTP //&lt;=== define this too
  ) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();

      this.platform.ready() 
      .then(() => {
          
          
        this.httpSSL.setServerTrustMode("pinned") //&lt;=== Add this function 
          .then(() => {
              console.log("Congratulaions, you have set up SSL Pinning.")
          })
          .catch(() => {
              console.error("Opss, SSL pinning failed.")
          });
          
          
      })

    });
  }
}
</pre></div>



<p>Now create new service folder to keep all our http service at one place something like below and create <code>api.service.ts</code> file </p>



<figure class="wp-block-image size-medium"><img loading="lazy" decoding="async" width="300" height="138" src="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-23.29.54-300x138.png" alt="" class="wp-image-2160" srcset="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-23.29.54-300x138.png 300w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-26-at-23.29.54.png 578w" sizes="auto, (max-width: 300px) 100vw, 300px" /></figure>



<p><code>api.service.ts</code></p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="typescript" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">import { Injectable } from '@angular/core';
import { HTTP } from '@ionic-native/http/ngx';

@Injectable({
  providedIn: 'root'
})
export class ApiService {
    
    readonly  apiEndPoint = 'https://otricks.com/api/user';
    readonly  fakeEndPoint = 'http://www.google.com/api/xyz'
    
    // This will get work with SSL Pinning becuase API endpoint is same as our certificate 
    getDataFromActualAPi(){
        return this.http.get(`apiEndPoint`,{}, {});
    }
    
    
    // This call will be fail as the domain is not correct according to our certificate.
    getDataFromFakeApi(){
        return this.http.get(`fakeEndPoint`,{}, {});
    }

}</pre></div>



<p></p>



<p>When you call this API service in the component <code>getDataFromActualAPi()</code> will return your correct response, however, if you try to call <code>getDataFromFakeApi()</code> the function will fail as the provided certificate is not from this domain.</p>



<p>The system will throw below error message, you can check in the debugger console.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="javascript" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">{status: -2, error: "TLS connection could not be established: javax.net…n: Trust anchor for certification path not found."}
error: "TLS connection could not be established: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found."
status: -2
}</pre></div>



<p>Hope this will help someone 🙂  if you like this article you may want to check how to <a href="https://otricks.com/how-to-secure-your-ubuntu-server-from-brute-force-attacks/">protect your server </a></p>





<p></p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-implement-ssl-pinning-in-ionic-5-or-html5-app/">How to implement SSL Pinning in Ionic 5?</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Ideal setup for working with nodejs typescript in VS code?</title>
		<link>https://otricks.com/what-is-the-ideal-setup-for-working-with-nodejs-typescript-in-vs-code/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Fri, 20 Mar 2020 19:30:46 +0000</pubDate>
				<category><![CDATA[Nodejs]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2105</guid>

					<description><![CDATA[<p>I was a very big fan of nodemon for a long time. for those who don&#8217;t have any idea about nodemon, it&#8217;s file watcher that&#8217;s&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/what-is-the-ideal-setup-for-working-with-nodejs-typescript-in-vs-code/">Ideal setup for working with nodejs typescript in VS code?</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>I was a very big fan of <a href="https://www.npmjs.com/package/nodemon">nodemon</a> for a long time. for those who don&#8217;t have any idea about nodemon, it&#8217;s file watcher that&#8217;s looking for any change in any file and refreshes the project to see those changes. In nodejs ecosystem, its uses for debugging purpose which was very helpful. however on the other side its eat up all the system resource. </p>



<p>Now I have switched from nodemon to new amazing <a href="https://www.npmjs.com/package/ts-node-dev">ts-node-dev</a> as stated in npm site</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>It restarts target node process when any of required files changes (as standard <code>node-dev</code>) but shares <a href="https://github.com/Microsoft/TypeScript/">Typescript</a> compilation process between restarts. This significantly increases speed of restarting comparing to <code>node-dev -r ts-node/register ...</code>, <code>nodemon -x ts-node ...</code> variations because there is no need to instantiate <code>ts-node</code> compilation each time.</p></blockquote>



<p>I will show my vs code setup for typescript which auto recompile and uses ts-node-dev package for any file change event.</p>



<h2 class="wp-block-heading">Setup vs code for typescript </h2>



<p>Create a new project in your computer</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">mkdir dummyProject
cd dummyProject</pre></div>



<p>I will be using npm as my package manager, let&#8217;s create a new package with default settings with below command </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">npm init -y</pre></div>



<p>It will generate a new file as a package.json </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">{
  "name": "dummyProject",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}</pre></div>



<p>Add typescript,  ts-node-dev and create new src folder with index.ts file inside.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">npm install typescript ts-node-dev --save-dev
</pre></div>



<p>Open package.json file and add below script inside the scripts block.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">"dev": "ts-node-dev --respawn --transpileOnly src/index.ts"
"dev:debug": "ts-node-dev --inspect=4321 --respawn --transpileOnly src/index.ts"</pre></div>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">{
  "name": "dummyProject",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "ts-node-dev --respawn --transpileOnly src/index.ts",
    "dev:debug": "ts-node-dev --inspect=4321 --respawn --transpileOnly src/index.ts"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
</pre></div>



<h2 class="wp-block-heading">Visual studio code debugging</h2>



<p>Inside visual studio code, we can add a breakpoint in the typescript code which can stop at certain points. Inside your root directory of the current project.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">mkdir .vscode
cd .vscode
touch launch.json</pre></div>



<p>Paste the following into your <code>launch.json</code> which we have created the previous step.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to dev:debug",
      "protocol": "inspector",
      "port": 4321,
      "restart": true,
      "cwd": "${workspaceRoot}"
    }
  ]
}</pre></div>



<p>Now do <code>npm run dev:debug</code> first in vs code terminal. once its&#8217; started then click on the debug button from the left  menu in VS code. it will open debugger panel something below.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="615" src="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-1024x615.png" alt="sample vs code with debugger step" class="wp-image-2117" srcset="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-1024x615.png 1024w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-300x180.png 300w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-768x461.png 768w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-1536x923.png 1536w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-2048x1231.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Check out other tips such as <a href="https://otricks.com/how-to-secure-your-ubuntu-server-from-brute-force-attacks/">How to secure ubuntu server</a> </p>
<p>The post <a rel="nofollow" href="https://otricks.com/what-is-the-ideal-setup-for-working-with-nodejs-typescript-in-vs-code/">Ideal setup for working with nodejs typescript in VS code?</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Best &#038; free google chrome plugin with HD wallpaper, world time, quotes with many more..</title>
		<link>https://otricks.com/replace-your-boring-chrome-tab-screen-with-an-amazing-tab-it-has-lots-of-features-functionality-install-it-get-amazed/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Sat, 14 Mar 2020 14:18:43 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[plugin]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2075</guid>

					<description><![CDATA[<p>When we start a new page/ new tab, we want something amazing from the chrome tab. A great HD wallpaper with clocks/ Timers world time&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/replace-your-boring-chrome-tab-screen-with-an-amazing-tab-it-has-lots-of-features-functionality-install-it-get-amazed/">Best &#038; free google chrome plugin with HD wallpaper, world time, quotes with many more..</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When we start a new page/ new tab, we want something amazing from the chrome tab. A great HD wallpaper with clocks/ Timers world time with different timezones, custom images with dynamically generated patterns.</p>



<p>We have covered all the great features including, world&#8217;s best photo from great photographers, best quotes to get motivated and inspire every day, add new abstract patterns to show your creativity and imagination, view the current time and set world clock with a different timezone that could be useful if you are working on multiple locations and want to see a quick time.</p>



<p>New Amazing Tab will be free forever for people like you and me</p>



<p>Features list</p>



<ul class="wp-block-list"><li>Get amazed with a fresh image every day from world-class photographers.</li><li>Create wallpaper patterns, to show your creative side. save created pattern into a photo album.</li><li>Change wallpaper image or set your own image as a wallpaper image.</li><li>Set Image change on every new tab open or every hour.</li><li>Search images from millions of images and set as wallpaper.</li><li>Get images from already crafted categories to suit your choice.</li><li>Set multiple clocks to have different timezones time with your custom names.</li><li>Set master clock with different styles, such as Rotary clock, Classical clock, Digital clock, and 3D clock.</li><li>Get motivated every day with the best quotes, you can change or add to favorite your quote.</li><li>Set Salat times (Muslim prayer) based on your current location or set the different locations of your choice.</li></ul>



<p>Please download it from the chrome store and provide your feedback.</p>



<pre class="wp-block-preformatted"><a href="https://chrome.google.com/webstore/detail/new-amazing-tab/ekbpbniminfcdefejlmipbdcnoblhamb?h1=en" class="rank-math-link">https://chrome.google.com/webstore/detail/new-amazing-tab/ekbpbniminfcdefejlmipbdcnoblhamb?h1=en</a></pre>



<figure class="wp-block-gallery aligncenter columns-3 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="640" height="400" src="https://otricks.com/wp-content/uploads/2020/03/tab-5.jpg" alt="" data-id="2079" data-full-url="https://otricks.com/wp-content/uploads/2020/03/tab-5.jpg" data-link="https://otricks.com/?attachment_id=2079" class="wp-image-2079" srcset="https://otricks.com/wp-content/uploads/2020/03/tab-5.jpg 640w, https://otricks.com/wp-content/uploads/2020/03/tab-5-300x188.jpg 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="640" height="400" src="https://otricks.com/wp-content/uploads/2020/03/tab-2.jpg" alt="" data-id="2082" data-full-url="https://otricks.com/wp-content/uploads/2020/03/tab-2.jpg" data-link="https://otricks.com/?attachment_id=2082" class="wp-image-2082" srcset="https://otricks.com/wp-content/uploads/2020/03/tab-2.jpg 640w, https://otricks.com/wp-content/uploads/2020/03/tab-2-300x188.jpg 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="640" height="400" src="https://otricks.com/wp-content/uploads/2020/03/tab-3.jpg" alt="" data-id="2081" data-full-url="https://otricks.com/wp-content/uploads/2020/03/tab-3.jpg" data-link="https://otricks.com/?attachment_id=2081" class="wp-image-2081" srcset="https://otricks.com/wp-content/uploads/2020/03/tab-3.jpg 640w, https://otricks.com/wp-content/uploads/2020/03/tab-3-300x188.jpg 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="640" height="400" src="https://otricks.com/wp-content/uploads/2020/03/tab-1.jpg" alt="" data-id="2078" data-full-url="https://otricks.com/wp-content/uploads/2020/03/tab-1.jpg" data-link="https://otricks.com/?attachment_id=2078" class="wp-image-2078" srcset="https://otricks.com/wp-content/uploads/2020/03/tab-1.jpg 640w, https://otricks.com/wp-content/uploads/2020/03/tab-1-300x188.jpg 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="640" height="400" src="https://otricks.com/wp-content/uploads/2020/03/tab-4.jpg" alt="" data-id="2080" data-full-url="https://otricks.com/wp-content/uploads/2020/03/tab-4.jpg" data-link="https://otricks.com/?attachment_id=2080" class="wp-image-2080" srcset="https://otricks.com/wp-content/uploads/2020/03/tab-4.jpg 640w, https://otricks.com/wp-content/uploads/2020/03/tab-4-300x188.jpg 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure></li></ul></figure>
<p>The post <a rel="nofollow" href="https://otricks.com/replace-your-boring-chrome-tab-screen-with-an-amazing-tab-it-has-lots-of-features-functionality-install-it-get-amazed/">Best &#038; free google chrome plugin with HD wallpaper, world time, quotes with many more..</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Manage Multiple version of Node in a single machine</title>
		<link>https://otricks.com/manage-multiple-version-of-node-in-a-single-machine/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Fri, 06 Mar 2020 13:32:07 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Nodejs]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2049</guid>

					<description><![CDATA[<p>When we start using node.js as our primary framework for writing multiple applications, Over the time it will be really pain in the neck, to&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/manage-multiple-version-of-node-in-a-single-machine/">Manage Multiple version of Node in a single machine</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When we start using node.js as our primary framework for writing multiple applications, Over the time it will be really pain in the neck, to manage older projects or projects with different node versions. </p>



<p>While working on angularjs to angualr 9 or ionic to ionic 5, I have a variety of node versions in different projects. Node community has also faced similar problems, to rescue there is a package to manage different versions of the node in a single computer, without uninstalling or re-installing your required version.</p>



<p>  You can install <a href="https://github.com/nvm-sh/nvm" class="rank-math-link">https://github.com/nvm-sh/nvm</a> in your computer to manage node</p>



<p>Once install its very easy to change your desire node version. To download, compile, and install the latest release of the node, do this:</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-admin-page" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="javascript" data-theme="monokai" data-fontsize="12" data-lines="Infinity" data-showlines="true" data-copy="true">nvm install node # "node" is an alias for the latest version</pre></div>
<p>The post <a rel="nofollow" href="https://otricks.com/manage-multiple-version-of-node-in-a-single-machine/">Manage Multiple version of Node in a single machine</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
