<?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: Pantelis Papasavvas</title>
    <description>The latest articles on DEV Community by Pantelis Papasavvas (@pantpapasavvas).</description>
    <link>https://dev.to/pantpapasavvas</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%2F553010%2F58fb7139-1cce-4291-a415-6bd0af54a4d4.jpg</url>
      <title>DEV Community: Pantelis Papasavvas</title>
      <link>https://dev.to/pantpapasavvas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pantpapasavvas"/>
    <language>en</language>
    <item>
      <title>Debug a NestJS application in WebStorm</title>
      <dc:creator>Pantelis Papasavvas</dc:creator>
      <pubDate>Mon, 10 Nov 2025 22:02:39 +0000</pubDate>
      <link>https://dev.to/pantpapasavvas/debug-a-nestjs-application-in-webstorm-5990</link>
      <guid>https://dev.to/pantpapasavvas/debug-a-nestjs-application-in-webstorm-5990</guid>
      <description>&lt;p&gt;NestJS is a &lt;strong&gt;progressive framework&lt;/strong&gt; that helps developers build &lt;strong&gt;scalable, maintainable, and testable&lt;/strong&gt; backend applications using modern &lt;strong&gt;JavaScript&lt;/strong&gt; and &lt;strong&gt;TypeScript&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It's built on top of &lt;strong&gt;Express&lt;/strong&gt;, but optionally you can configure it to use &lt;strong&gt;Fastify&lt;/strong&gt; as well, and embraces concepts like &lt;strong&gt;dependency injection&lt;/strong&gt;, &lt;strong&gt;modularity&lt;/strong&gt;, and &lt;strong&gt;decorators&lt;/strong&gt;, making backend development cleaner and more predictable.&lt;/p&gt;

&lt;p&gt;But even with a powerful framework like NestJS, there is one skill every developer needs — and that is &lt;strong&gt;debugging&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Why debugging matters
&lt;/h2&gt;

&lt;p&gt;As developers, we face many unexpected issues daily — from logical bugs to missing async calls.&lt;br&gt;&lt;br&gt;
Adding &lt;code&gt;console.log()&lt;/code&gt; everywhere might work for quick fixes, but it's far from efficient.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;real debugging&lt;/strong&gt; comes into play.&lt;/p&gt;

&lt;p&gt;Setting up proper debugging allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pause the code execution where you want
&lt;/li&gt;
&lt;li&gt;Inspect variables in real time
&lt;/li&gt;
&lt;li&gt;Step through the logic line by line
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, if you try to set a breakpoint in a NestJS project, you’ll notice that the execution doesn't stop where you expect.&lt;/p&gt;

&lt;p&gt;So let’s fix that.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ Setting up the Debug Configuration in WebStorm
&lt;/h2&gt;

&lt;p&gt;To debug a NestJS app in &lt;strong&gt;WebStorm&lt;/strong&gt;, we need to add a &lt;strong&gt;Run/Debug configuration&lt;/strong&gt;.&lt;/p&gt;




&lt;h4&gt;
  
  
  🔹 Open the configuration window
&lt;/h4&gt;

&lt;p&gt;In the top menu, go to:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Run → Edit Configurations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This will open the configuration window — something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F211rd0planxum3nvkvol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F211rd0planxum3nvkvol.png" alt=" " width="800" height="714"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  🔹 Create a new Node.js configuration
&lt;/h4&gt;

&lt;p&gt;Press the &lt;strong&gt;➕ (plus)&lt;/strong&gt; button in the top-left corner and select &lt;strong&gt;Node.js&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Then give your configuration a name like &lt;code&gt;NestJS Debug&lt;/code&gt; or something that makes sense to you.&lt;/p&gt;




&lt;h4&gt;
  
  
  🔹 Configure the Node.js settings
&lt;/h4&gt;

&lt;p&gt;Here’s what each field means and what to fill in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Node Interpreter&lt;/strong&gt; → This is the Node version used by your project.&lt;br&gt;&lt;br&gt;
Choose &lt;strong&gt;Project node (&lt;code&gt;some path&lt;/code&gt;)&lt;/strong&gt; — it’s usually preselected.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Working Directory&lt;/strong&gt; → The root folder of your NestJS project (where your &lt;code&gt;nest-cli.json&lt;/code&gt; lives).  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;File&lt;/strong&gt; → The path to the Nest CLI file. Normally, you will find it at:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  node_modules/@nestjs/cli/bin/nest.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the executable that runs your application.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application Parameters&lt;/strong&gt; → These are the arguments that tell Nest CLI what to do.
You can type:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  start --debug --watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  🔹 Understanding the parameters
&lt;/h4&gt;

&lt;p&gt;Let’s break down what these parameters actually do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;start&lt;/code&gt;: Tells NestJS to start the application.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--debug&lt;/code&gt;: Enables debugging mode, allowing WebStorm to attach breakpoints.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--watch&lt;/code&gt;: Enables live reload — every time you save a file, NestJS restarts automatically.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, in simple terms, we are telling Nest CLI:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Start my app in debug mode and keep watching for code changes.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fmk272vbw5t8cbea5oxzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fmk272vbw5t8cbea5oxzu.png" alt=" " width="800" height="720"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  🔹 Save and start debugging
&lt;/h4&gt;

&lt;p&gt;Now everything is set&lt;br&gt;
Press &lt;strong&gt;OK&lt;/strong&gt; to save your configuration, set your breakpoints, and hit the &lt;strong&gt;Debug&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;WebStorm will launch the application in debug mode, and you’ll be able to pause the execution exactly where you want it.&lt;/p&gt;




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

&lt;p&gt;Debugging is not just about fixing bugs — it’s about understanding how your code actually works.&lt;/p&gt;

&lt;p&gt;By applying this setup, you’ll spend less time guessing and more time improving your code.&lt;/p&gt;

&lt;p&gt;If you found this helpful, leave a ❤️ or a comment — it helps other developers discover it too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy debugging! ⚡&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>nestjs</category>
      <category>typescript</category>
      <category>webstorm</category>
    </item>
    <item>
      <title>Angular Components Lifecycle - Basics</title>
      <dc:creator>Pantelis Papasavvas</dc:creator>
      <pubDate>Mon, 29 Jan 2024 14:30:04 +0000</pubDate>
      <link>https://dev.to/pantpapasavvas/angular-components-lifecycle-basics-4f4o</link>
      <guid>https://dev.to/pantpapasavvas/angular-components-lifecycle-basics-4f4o</guid>
      <description>&lt;p&gt;As developers working with Angular, we rely on its lifecycle hooks to manage how our components are created, updated, and destroyed. Understanding these hooks is key to building reliable and high-performance applications.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore these essential lifecycle hooks offered by Angular, unraveling their roles and significance in the development process of robust, dynamic applications. &lt;br&gt;
Let's start&lt;/p&gt;

&lt;h2&gt;
  
  
  constructor
&lt;/h2&gt;

&lt;p&gt;This is a standard Javascript class constructor.&lt;br&gt;
Runs when Angular instantiates the component.&lt;/p&gt;

&lt;h2&gt;
  
  
  ngOnInit
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;ngOnInit&lt;/code&gt; runs when Angular has initialized the component's inputs.&lt;br&gt;
It runs only once before the component's template is initialized.&lt;br&gt;
Inside &lt;code&gt;ngOnInit&lt;/code&gt;, is a good place to fetch your initial data.&lt;/p&gt;

&lt;h2&gt;
  
  
  ngOnChanges
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ngOnChanges&lt;/code&gt; runs every time that an input value is changed.&lt;br&gt;
This happens before the template is initialized and the first &lt;code&gt;ngOnChanges&lt;/code&gt; will run before the &lt;code&gt;ngOnInit&lt;/code&gt;.&lt;br&gt;
Here you can update the component's state based on input values.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;ngOnChanges&lt;/code&gt; accepts an argument of type &lt;code&gt;SimpleChanges&lt;/code&gt;.&lt;br&gt;
This is an object that contains the input's previous value, its current value, and a flag for whether this is the first time the input has changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  ngDoCheck
&lt;/h2&gt;

&lt;p&gt;It runs every time Angular checks a component for changes.&lt;br&gt;
With this hook, we can manually check for changes outside of Angular's change detection and change the state of a component.&lt;/p&gt;

&lt;p&gt;Using this hook may affect the performance of the page and for that reason, we need to use it if we don't have anything else to do.&lt;br&gt;
In contrast with &lt;code&gt;ngOnChancges&lt;/code&gt;, the first &lt;code&gt;ngDoCheck&lt;/code&gt; runs after &lt;code&gt;ngOnInit&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  ngAfterViewInit
&lt;/h2&gt;

&lt;p&gt;As its name says, that hook runs after the template and its children have been initialized, and runs only one time.&lt;/p&gt;

&lt;h2&gt;
  
  
  ngOnDestroy
&lt;/h2&gt;

&lt;p&gt;This method runs once when the component is destroyed.&lt;br&gt;
This means that the component is not available in the DOM anymore.&lt;br&gt;
Keep in mind that if you have any subscriptions in the component you need to unsubscribe them. This is a good place to do that.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>angular</category>
      <category>typescript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Add spinner in Angular application with ngx-spinner</title>
      <dc:creator>Pantelis Papasavvas</dc:creator>
      <pubDate>Mon, 23 May 2022 21:47:37 +0000</pubDate>
      <link>https://dev.to/pantpapasavvas/add-spinner-in-angular-application-with-ngx-spinner-10an</link>
      <guid>https://dev.to/pantpapasavvas/add-spinner-in-angular-application-with-ngx-spinner-10an</guid>
      <description>&lt;p&gt;NgxSpinner is a library with more than 50 different loading spinners.&lt;br&gt;
It supports Angular 13 but is available and for older versions.&lt;/p&gt;

&lt;p&gt;Usually we want to use spinners to show that something happens and inform the user that our application is working. &lt;/p&gt;

&lt;p&gt;I use spinners when an API call is in progress.&lt;br&gt;
In this article, I am going to show a simple example of how to use spinners and I ll make use of setTimeout function.&lt;br&gt;
Of course you can add the spinner in a service or in your interceptor.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;In order to use it you must to install it.&lt;br&gt;
ngx-spinner is available via npm or yarn&lt;/p&gt;

&lt;p&gt;Open a console in your working directory&lt;br&gt;
If you prefer npm type 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;$ npm install ngx-spinner --save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you prefer yarn type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ yarn add ngx-spinner
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is also an option to add the spinner using angular-cli&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ng add ngx-spinner
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Imports
&lt;/h2&gt;

&lt;p&gt;The first thing we need to do is to add css animation files in angular.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "styles": [
    "node_modules/ngx-spinner/animations/ball-beat.css" 
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After doing that we need to import &lt;em&gt;BroswerAnimationModule&lt;/em&gt; and the &lt;em&gt;NgxSpinnerModule&lt;/em&gt; in the root module. Usually this will be the AppModule.&lt;/p&gt;

&lt;p&gt;So in our app.module.ts we need to add 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;import { NgxSpinnerModule } from 'ngx-spinner';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also we need to import &lt;em&gt;CUSTOM_ELEMENT_SCHEMA&lt;/em&gt; from @angular/core otherwise you will see an error in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then below the imports array we need to add schemas array and pass &lt;em&gt;CUSTOM_ELEMENT_SCHEMA&lt;/em&gt; there.&lt;/p&gt;

&lt;p&gt;Now our app.module.ts it looks like below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@NgModule({
  imports: [
    BrowserAnimationsModule,
    NgxSpinnerModule,
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use
&lt;/h2&gt;

&lt;p&gt;One last thing we need to import is the ngx-spinner service in order to use the functions that the service provides to us.&lt;br&gt;
Inject the service via constructor and use it on ngOnInit.&lt;br&gt;
So our app.component.ts will looks like below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NgxSpinnerService } from 'ngx-spinner';

class AppComponent implements OnInit {
  constructor(private spinner: NgxSpinnerService) {}

  ngOnInit() {
    this.spinner.show();
    setTimeout(() =&amp;gt; {
      this.spinner.hide();
    }, 5000);
  }
}

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

&lt;/div&gt;



&lt;p&gt;I use setTimeout in order to show how we can close the spinner.&lt;br&gt;
In this case the spinner will close after 5 seconds.&lt;/p&gt;

&lt;p&gt;Now that we setup everything we can use the spinner in our template like this&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;ngx-spinner type="ball-beat"&amp;gt;&amp;lt;/ngx-spinner&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks for reading and I am waiting for your comments.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Angular material table remove element by index with paginator</title>
      <dc:creator>Pantelis Papasavvas</dc:creator>
      <pubDate>Fri, 07 Jan 2022 08:21:19 +0000</pubDate>
      <link>https://dev.to/pantpapasavvas/angular-material-table-remove-element-by-index-with-paginator-449a</link>
      <guid>https://dev.to/pantpapasavvas/angular-material-table-remove-element-by-index-with-paginator-449a</guid>
      <description>&lt;p&gt;The easy way to implement this is to take the index of the row and apply the filter or the splice method to the dataSource.&lt;br&gt;
Ideally we are going to create a click on the delete button and then we are going to get the row index. After that and with the row index we are going to filter the dataSource to exclude the record with the same index as the index that we get from the click event.&lt;br&gt;
At this phase our code it will like look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.dataSource.data = this.dataSource.data
  .filter(item, index =&amp;gt; index !== selectedIndex );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works fine in all cases if we don’t have pagination on our material table.&lt;br&gt;
So what happens in the case that we want to delete a record that it is on the second or the third page of the table and not in the first page?&lt;/p&gt;
&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;The problem is that, when we have pagination on the material table, the row Index starts from zero in every page. For example, the first element of the first page has index 0 and the first element of the second page has again index 0. Actually, every first element on every page has index equals to 0.&lt;/p&gt;

&lt;p&gt;One solution to this is to follow the dataSource index.&lt;br&gt;
So the only thing that we need to do is to calculate the index every time that we want to remove an element.&lt;br&gt;
So from ngAfterViewInit we have available the table paginator&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngAfterViewInit() {
    this.dataSource.paginator = this.paginator;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this we have access in some properties that paginator has. The properties that we want here is the pageIndex and the pageSize.&lt;br&gt;
Then we can calculate the rowIndex and will be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rowIndex + (pageIndex * pageSize)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can create a function like below to remove the record from our table&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;delelteRecord(){
 const { pageIndex, pageSize } = paginator;
 const removeIndex = parentIndex + (pageIndex * pageSize);
 return dataSource.data.filter((i, index) =&amp;gt; index !== 
 removeIndex);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the rowIndex will follow the dataSource index and we are ready to apply the filter method in our dataSource to get the new dataSource and display it to the screen.&lt;/p&gt;

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