<?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: Kumar Ayush</title>
    <description>The latest articles on DEV Community by Kumar Ayush (@ayushssshhh).</description>
    <link>https://dev.to/ayushssshhh</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%2F2968660%2F13e3116a-5380-4cbf-9401-eeb5eb391211.png</url>
      <title>DEV Community: Kumar Ayush</title>
      <link>https://dev.to/ayushssshhh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ayushssshhh"/>
    <language>en</language>
    <item>
      <title>🌐 Mastering HTTP, HTTPS &amp; URL Modules in Node.js — The Foundation of Web Servers</title>
      <dc:creator>Kumar Ayush</dc:creator>
      <pubDate>Wed, 02 Jul 2025 18:16:05 +0000</pubDate>
      <link>https://dev.to/ayushssshhh/mastering-http-https-url-modules-in-nodejs-the-foundation-of-web-servers-2e6l</link>
      <guid>https://dev.to/ayushssshhh/mastering-http-https-url-modules-in-nodejs-the-foundation-of-web-servers-2e6l</guid>
      <description>&lt;p&gt;When working with Node.js, one of the core capabilities it offers is to create web servers from scratch using native modules — no frameworks like Express needed (though they help a lot!).&lt;/p&gt;

&lt;p&gt;In this blog, we’ll explore three key core modules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;http – build your own basic web server&lt;/li&gt;
&lt;li&gt;https – build secure servers using SSL/TLS&lt;/li&gt;
&lt;li&gt;url – parse and manipulate URLs like a pro&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We’ll also compare these native approaches with Express.js to see why frameworks matter.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;📦 1. The HTTP Module — Your First Node.js Server&lt;/strong&gt;&lt;br&gt;
Node.js provides a built-in http module that allows you to spin up a web server without using Express or any third-party library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 Concept&lt;/strong&gt;&lt;br&gt;
An HTTP server listens for incoming requests on a port.&lt;br&gt;
It then sends back responses based on the request URL or method.&lt;br&gt;
💡 Basic Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const http = require('http');

const server = http.createServer((req, res) =&amp;gt; {
  if (req.url === '/') {
    res.end('Welcome to the Home Page');
  } else if (req.url === '/about') {
    res.end('About Page');
  } else {
    res.end('404 Not Found');
  }
});
server.listen(3000, () =&amp;gt; {
  console.log('Server running at http://localhost:3000');
});
🔍 Breakdown
http.createServer(callback) – sets up a server
req.url – gives the URL path
res.end() – ends the response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;🔐 2. The HTTPS Module — Secure Your Communication&lt;/strong&gt;&lt;br&gt;
While http is great, it’s not secure. That’s where https comes in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Why Use HTTPS?&lt;/strong&gt;&lt;br&gt;
Encrypts communication (SSL/TLS)&lt;br&gt;
Mandatory for handling passwords, payments, etc.&lt;br&gt;
Required in production environments&lt;br&gt;
📁 Prerequisite: SSL Certificates&lt;br&gt;
You need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A private key (key.pem)&lt;/li&gt;
&lt;li&gt;A certificate (cert.pem)
Generate self-signed ones for testing:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;openssl req -nodes -new -x509 -keyout key.pem -out cert.pem&lt;/code&gt;&lt;br&gt;
💡 HTTPS Server Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const https = require('https');
const fs = require('fs');

const options = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem')
};
https.createServer(options, (req, res) =&amp;gt; {
  res.writeHead(200);
  res.end('Hello from Secure HTTPS Server!');
}).listen(4433, () =&amp;gt; {
  console.log('HTTPS Server running on https://localhost:4433');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;🌐 3. The URL Module — Parsing Made Simple&lt;/strong&gt;&lt;br&gt;
Want to extract ?term=react or /products from incoming requests? That’s what the url module is for.&lt;/p&gt;

&lt;p&gt;💡 Modern URL Parsing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { URL } = require('url');

const myURL = new URL('https://example.com/products?category=books&amp;amp;id=101');
console.log(myURL.hostname);  // example.com
console.log(myURL.pathname);  // /products
console.log(myURL.searchParams.get('category')); // books
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;🔁 Comparing: Native https vs Express&lt;/strong&gt;&lt;br&gt;
Let’s see how things differ between native Node.js and Express.&lt;/p&gt;

&lt;p&gt;🧪 Task: Parse /search?term=react&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Using Native HTTPS:
const https = require('https');
const fs = require('fs');
const { URL } = require('url');

const options = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem')
};

https.createServer(options, (req, res) =&amp;gt; {
  const fullUrl = `https://${req.headers.host}${req.url}`;
  const parsedUrl = new URL(fullUrl);
  if (parsedUrl.pathname === '/search') {
    const term = parsedUrl.searchParams.get('term') || 'none';
    res.writeHead(200, { 'Content-Type': 'application/json' });
    res.end(JSON.stringify({ message: 'Search term received', term }));
  } else {
    res.writeHead(404);
    res.end('404 Not Found');
  }
}).listen(4433);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using Express (Much Simpler!)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const https = require('https');
const fs = require('fs');

const app = express();
const options = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem')
};

app.get('/search', (req, res) =&amp;gt; {
  const term = req.query.term || 'none';
  res.status(200).json({ message: 'Search term received', term });
});
https.createServer(options, app).listen(4433, () =&amp;gt; {
  console.log('Express HTTPS server running at https://localhost:4433');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;🔧 Bonus: Middleware Example in Express&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const morgan = require('morgan');
app.use(morgan('dev')); // Logs every incoming request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In native https, you'd have to code logging, parsing, etc., all manually!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;🎯 Conclusion&lt;/strong&gt;&lt;br&gt;
Understanding how Node.js works at the core level gives you control and insight into what frameworks like Express abstract away. Here’s what we learned:&lt;/p&gt;

&lt;p&gt;Use http or https for learning or small utilities.&lt;br&gt;
For production-grade apps, always use https with SSL.&lt;br&gt;
Use the modern URL class for parsing.&lt;br&gt;
Express makes development faster, cleaner, and more scalable.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;🧪 Try It Yourself&lt;/strong&gt;&lt;br&gt;
✅ Generate SSL certs&lt;br&gt;
✅ Build both native and Express-based HTTPS servers&lt;br&gt;
✅ Parse query parameters from /search?term=yourvalue&lt;/p&gt;

&lt;p&gt;Then… compare your code and see why Express is a game-changer!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>backend</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>🔍 Demystifying Node.js Core Modules: A Practical Dive into fs and path</title>
      <dc:creator>Kumar Ayush</dc:creator>
      <pubDate>Mon, 30 Jun 2025 18:39:28 +0000</pubDate>
      <link>https://dev.to/ayushssshhh/demystifying-nodejs-core-modules-a-practical-dive-into-fs-and-path-i0l</link>
      <guid>https://dev.to/ayushssshhh/demystifying-nodejs-core-modules-a-practical-dive-into-fs-and-path-i0l</guid>
      <description>&lt;p&gt;Whether you're just diving into backend development or brushing up on Node.js fundamentals, understanding the built-in fs and path modules is a game changer. These core modules—available without any external installation—lay the groundwork for working efficiently with files and directories across platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;🚀 Why Core Modules Matter&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Node.js ships with powerful internal tools like fs (file system) and path (path utilities) to help developers:&lt;/p&gt;

&lt;p&gt;Read, write, and manage files with ease&lt;/p&gt;

&lt;p&gt;Build platform-agnostic paths that work seamlessly across Windows, Linux, and macOS&lt;/p&gt;

&lt;p&gt;Let’s explore how these tools fit into your developer toolkit.&lt;/p&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;📁 Working with the fs Module&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
The fs module allows both synchronous and asynchronous file operations—ideal for learning and production use respectively.&lt;/p&gt;

&lt;p&gt;**✍️ Writing Files&lt;br&gt;
**js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Synchronous
fs.writeFileSync('example.txt', 'Hello, Node.js!');

// Asynchronous
fs.writeFile('exampleAsync.txt', 'Async Hello!', (err) =&amp;gt; {
  if (err) throw err;
  console.log('File created!');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;📖 Reading Files&lt;/strong&gt;&lt;br&gt;
js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Synchronous
const data = fs.readFileSync('example.txt', 'utf-8');
console.log(data);

// Asynchronous
fs.readFile('exampleAsync.txt', 'utf-8', (err, data) =&amp;gt; {
  if (err) throw err;
  console.log(data);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;➕ Appending Content&lt;/strong&gt;&lt;br&gt;
js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fs.appendFileSync('example.txt', '\nThis is a new line.');
fs.appendFile('example.txt', '\nAsync line here.', (err) =&amp;gt; {
  if (err) throw err;
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🗑️ Deleting Files&lt;/strong&gt;&lt;br&gt;
js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fs.unlinkSync('example.txt');
fs.unlink('exampleAsync.txt', (err) =&amp;gt; {
  if (err) throw err;
  console.log('File deleted!');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🗂️ Directories and Listing Contents&lt;/strong&gt;&lt;br&gt;
js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create folder
fs.mkdirSync('myFolder');

// Read current directory
const files = fs.readdirSync('.');
console.log(files);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;em&gt;&lt;strong&gt;🧭 Navigating with the path Module&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
The path module keeps your file paths robust and cross-platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ Common Utilities&lt;/strong&gt;&lt;br&gt;
js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const path = require('path');

// Joins segments into a normalized path
const filePath = path.join('folder', 'file.txt');

// Gets full absolute path
const absolutePath = path.resolve('folder', 'file.txt');

// Extracts file name, dir, and extension
const base = path.basename('/users/kumar/index.js');
const dir = path.dirname('/users/kumar/index.js');
const ext = path.extname('index.js');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🧪 Utility Checks&lt;/strong&gt;&lt;br&gt;
js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;path.isAbsolute('/folder/file.txt');  // true
path.normalize('folder/../folder2/./file.txt');  // 'folder2/file.txt'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🤝 In Tandem: fs + path&lt;/strong&gt;&lt;br&gt;
js&lt;br&gt;
&lt;strong&gt;const fullPath = path.join(__dirname, 'notes', 'todo.txt');&lt;br&gt;
fs.writeFileSync(fullPath, 'Complete MERN Day 2');&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;🎯 Wrap-Up&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
The fs and path modules offer an elegant way to work with files in a platform-safe, efficient manner. Mastering them early on sets the foundation for scalable file operations in real-world applications.&lt;/p&gt;

&lt;p&gt;Stay tuned as I continue my MERN stack journey—next up, diving into server-side routing and handling requests using Express.js!!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>node</category>
      <category>mern</category>
    </item>
    <item>
      <title>🚀 Just dropped a beginner-friendly deep dive into Node.js—exploring its event-driven architecture, non-blocking I/O, and why it’s a game-changer for modern backend development.</title>
      <dc:creator>Kumar Ayush</dc:creator>
      <pubDate>Sun, 29 Jun 2025 18:09:08 +0000</pubDate>
      <link>https://dev.to/ayushssshhh/just-dropped-a-beginner-friendly-deep-dive-into-nodejs-exploring-its-event-driven-architecture-5hd5</link>
      <guid>https://dev.to/ayushssshhh/just-dropped-a-beginner-friendly-deep-dive-into-nodejs-exploring-its-event-driven-architecture-5hd5</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/ayushssshhh/getting-started-with-nodejs-a-beginners-guide-3nj6" class="crayons-story__hidden-navigation-link"&gt;Getting Started with Node.js: A Beginner’s Guide&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/ayushssshhh" class="crayons-avatar  crayons-avatar--l  "&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%2Fuser%2Fprofile_image%2F2968660%2F13e3116a-5380-4cbf-9401-eeb5eb391211.png" alt="ayushssshhh profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/ayushssshhh" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Kumar Ayush
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Kumar Ayush
                
              
              &lt;div id="story-author-preview-content-2636540" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/ayushssshhh" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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%2Fuser%2Fprofile_image%2F2968660%2F13e3116a-5380-4cbf-9401-eeb5eb391211.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Kumar Ayush&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/ayushssshhh/getting-started-with-nodejs-a-beginners-guide-3nj6" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 29 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/ayushssshhh/getting-started-with-nodejs-a-beginners-guide-3nj6" id="article-link-2636540"&gt;
          Getting Started with Node.js: A Beginner’s Guide
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/backend"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;backend&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/node"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;node&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/webdev"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;webdev&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
            &lt;a href="https://dev.to/ayushssshhh/getting-started-with-nodejs-a-beginners-guide-3nj6#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            2 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>backend</category>
      <category>node</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Getting Started with Node.js: A Beginner’s Guide</title>
      <dc:creator>Kumar Ayush</dc:creator>
      <pubDate>Sun, 29 Jun 2025 18:00:19 +0000</pubDate>
      <link>https://dev.to/ayushssshhh/getting-started-with-nodejs-a-beginners-guide-3nj6</link>
      <guid>https://dev.to/ayushssshhh/getting-started-with-nodejs-a-beginners-guide-3nj6</guid>
      <description>&lt;p&gt;JavaScript has long been a front-end favorite, powering interactive experiences in browsers. But what if you could bring that same language to your server-side code? Enter Node.js—a lightweight, powerful runtime that lets you run JavaScript outside the browser.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;&lt;strong&gt;🔍 What Is Node.js??&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Node.js&lt;/strong&gt; is an open-source, cross-platform JavaScript runtime built on Chrome’s blazing-fast &lt;strong&gt;V8 engine&lt;/strong&gt;. It enables developers to build scalable network applications using JavaScript—on the &lt;strong&gt;backend&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of Node as your way to bring JavaScript everywhere—from browser to server, from simple scripts to full-blown APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;✨ Key Features That Make Node.js Shine&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Single-threaded but scalable:&lt;/strong&gt; Handles multiple tasks with one thread using smart asynchronous operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-blocking I/O:&lt;/strong&gt; Keeps the event loop flowing, allowing it to handle multiple requests without waiting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Built-in modules:&lt;/strong&gt; Native support for the file system, HTTP, streams, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;npm ecosystem:&lt;/strong&gt; Access to a massive library of packages via Node Package Manager.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-time magic:&lt;/strong&gt; Perfect for apps like chats, games, and live dashboards.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;🧠 Under the Hood: How Node.js Works&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
At first glance, using a single thread for all your server logic sounds... risky. But Node makes it work with a clever mechanism:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;🌀 The Event Loop&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Node is &lt;strong&gt;event-driven—&lt;/strong&gt;it doesn’t block the thread while waiting for tasks like file reading or database calls. Instead:&lt;/p&gt;

&lt;p&gt;It delegates long tasks to the system.&lt;/p&gt;

&lt;p&gt;Keeps accepting new tasks while others are “in progress.”&lt;/p&gt;

&lt;p&gt;When those tasks complete, Node gets notified and calls your callback functions.&lt;/p&gt;

&lt;p&gt;It’s like a restaurant where the chef (Node) doesn’t cook everything personally but delegates certain items, keeps taking new orders, and calls the server when food’s ready.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;⏱️ A Quick Example: setTimeout&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("Start");

setTimeout(() =&amp;gt; {
  console.log("Inside Timeout");
}, 0);

console.log("End");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Start
End
Inside Timeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even with a 0ms delay, the function gets queued and executed after the synchronous code finishes. That’s the event loop in action!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;🆚 Blocking vs Non-Blocking Code&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔒 Blocking:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const data = fs.readFileSync('file.txt');
console.log(data.toString());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This pauses everything until the file is read.&lt;br&gt;
&lt;strong&gt;🔓 Non-Blocking:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fs.readFile('file.txt', (err, data) =&amp;gt; {
  console.log(data.toString());
});
console.log("File read requested...");

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

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;&lt;em&gt;🎯 When Should You Use Node.js??&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Node excels when:&lt;/p&gt;

&lt;p&gt;You’re building &lt;strong&gt;REST APIs&lt;/strong&gt; and services&lt;/p&gt;

&lt;p&gt;You want &lt;strong&gt;real-time apps&lt;/strong&gt; (chat, games, live updates)&lt;/p&gt;

&lt;p&gt;You need custom &lt;strong&gt;CLI tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You want server-side rendering or streaming data&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;🌟 Final Thoughts&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
If you’re looking to build fast, modern, real-time applications—all while speaking the JavaScript you already know—Node.js is your gateway to full-stack brilliance. Its non-blocking model, rich ecosystem, and performance make it an excellent choice for developers of all levels.&lt;/p&gt;

&lt;p&gt;Curious where to go from here? Next up: dive into setting up your first Node.js server!&lt;/p&gt;

</description>
      <category>backend</category>
      <category>node</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>System Design : Observer Design Patterns</title>
      <dc:creator>Kumar Ayush</dc:creator>
      <pubDate>Sun, 23 Mar 2025 18:14:22 +0000</pubDate>
      <link>https://dev.to/ayushssshhh/system-design-series-day-2-observer-design-patterns-4g64</link>
      <guid>https://dev.to/ayushssshhh/system-design-series-day-2-observer-design-patterns-4g64</guid>
      <description>&lt;p&gt;Welcome to Day 2 of my System Design Learning Series! Today, let's dive into Design Patterns, Observer Pattern.&lt;br&gt;
 📌 Use Case: Payment methods in e-commerce (Credit Card, PayPal, UPI).&lt;br&gt;
🔹 Observer Design Pattern (Brief Overview)&lt;br&gt;
The Observer Pattern establishes a one-to-many dependency between objects, so when one object (Observable) changes, all dependent objects (Observers) are notified.&lt;br&gt;
 📌 Use Case: Notification systems, event listeners, stock price updates.&lt;br&gt;
🔍 Deep Dive: Observer Pattern – Walmart SDE Interview Question&lt;br&gt;
❓ Implement a notify function to notify all subscribers when an event occurs.&lt;br&gt;
💡 Solution:&lt;br&gt;
 1️⃣ Define an Observable (Publisher) that maintains a list of observers.&lt;br&gt;
 2️⃣ Implement attach, detach, and notify methods.&lt;br&gt;
 3️⃣ Product extends Observable : Whenever the product properties changes, all observers get updated.&lt;br&gt;
 4️⃣ The Observers (Subscribers) react when notified.&lt;/p&gt;

&lt;p&gt;Here’s the Observer Pattern implementation for the problem using javascript​:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Observable {
 constructor() { 
 this.observers = []; //maintaining list of observer
 }

 attach(observer) {
 this.observers.push(observer); //adding new observer
 }

 detach(observer) {
 this.observers = this.observers.filter(obs =&amp;gt; obs !== observer); 
 //removing an observer in case of unsubscribing from notification service
 }

 notify(data) {
 this.observers.forEach(observer =&amp;gt; observer.update(data));
 }
}

class Product extends Observable {
 constructor(name, price) {
 super();
 this._name = name;
 this._price = price;
 }

// calling notify() whenever product value changes
 set name(newName) {
 this._name = newName;
 this.notify(`Product name updated to: ${newName}`);
 }

 set price(newPrice) {
 this._price = newPrice;
 this.notify(`Price updated to: $${newPrice}`);
 }
}


// creating an observer class to identify each observer
class Observer {
 constructor(name) {
 this.name = name;
 }

 update(message) {
 console.log(`${this.name} received update: ${message}`);
 }
}

// Usage Example:
const product = new Product("Laptop", 1000);

const observer1 = new Observer("Observer 1");
const observer2 = new Observer("Observer 2");

product.attach(observer1);
product.attach(observer2);

product.price = 1200; // Notifies observers
product.name = "Gaming Laptop"; // Notifies observers

observable.notify("New Event Occurred!"); // Both observers get notified

const product = new Product("Laptop", 1000);

const observer1 = new Observer("Observer 1");
const observer2 = new Observer("Observer 2");

product.attach(observer1);
product.attach(observer2);

product.price = 1200; // Notifies observers
product.name = "Gaming Laptop"; // Notifies observers

observable.notify("New Event Occurred!"); // Both observers get notified
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🌟 Key Takeaways&lt;br&gt;
✅ Loose Coupling: The observable and observers interact with minimal dependency.&lt;br&gt;
 ✅ Flexibility: New observers can be added/removed dynamically.&lt;br&gt;
 ✅ Real-World Use Cases: Notification services, stock market updates, event-driven systems.&lt;br&gt;
What’s your take on the Observer Pattern? Have you encountered it in real-world scenarios? Let’s discuss in the comments! 🚀&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>programming</category>
      <category>lld</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
