<?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: Ali Hamza</title>
    <description>The latest articles on DEV Community by Ali Hamza (@ali_hamza_589ec7b3eb6688d).</description>
    <link>https://dev.to/ali_hamza_589ec7b3eb6688d</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3939488%2Fffc69754-c900-4599-b972-2a8d900525dd.png</url>
      <title>DEV Community: Ali Hamza</title>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ali_hamza_589ec7b3eb6688d"/>
    <language>en</language>
    <item>
      <title>Day 180 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 13:45:03 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-180-of-learning-mern-stack-50mh</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-180-of-learning-mern-stack-50mh</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 180&lt;/strong&gt; of my full-stack engineering track! Today, I designed and built the &lt;strong&gt;Credit-Based Pricing Page UI&lt;/strong&gt; for my &lt;strong&gt;AI Website Builder&lt;/strong&gt; platform! 🚀💳&lt;/p&gt;

&lt;p&gt;Here is a breakdown of how I structured the pricing matrix and integrated type-safe component mapping in React &amp;amp; TypeScript.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Architecture &amp;amp; UI Breakdown
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Type-Safe Pricing Contracts
&lt;/h3&gt;

&lt;p&gt;Defined strict TypeScript contracts to govern plan tiers, pricing calculations, credit caps, and feature lists:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
interface Plan {
  id: string;
  name: string;
  price: number;
  credits: number;
  description: string;
  features: string[];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>ai</category>
      <category>typescript</category>
      <category>react</category>
      <category>ui</category>
    </item>
    <item>
      <title>Day 179 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 13:39:25 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-179-of-learning-mern-stack-3l4e</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-179-of-learning-mern-stack-3l4e</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is &lt;strong&gt;Day 179&lt;/strong&gt; of my full-stack engineering milestone journey! Today, I built the &lt;strong&gt;My Projects Dashboard UI&lt;/strong&gt; for the &lt;strong&gt;AI Website Builder&lt;/strong&gt; platform! 🚀🎨&lt;/p&gt;

&lt;p&gt;Here is a breakdown of how I designed a card grid layout with dynamic live preview rendering using TypeScript and React.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Architecture &amp;amp; UI Highlights
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Miniature Live Previews via Scaled iFrames
&lt;/h3&gt;

&lt;p&gt;Instead of storing static preview thumbnails, I embedded live preview previews using scaled &lt;code&gt;iframe&lt;/code&gt; rendering directly from stored markup strings:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
tsx
&amp;lt;iframe
  srcDoc={project.current_code}
  className="absolute top-0 left-0 w-[1200px] h-[800px] origin-top-left pointer-events-none"
  sandbox="allow-scripts allow-same-origin"
  style={{ transform: 'scale(0.25)' }}
/&amp;gt; const [loading, setLoading] = useState&amp;lt;boolean&amp;gt;(true);
const [projects, setProjects] = useState&amp;lt;Project[]&amp;gt;([]);

const deleteProject = async (projectId: string) =&amp;gt; {
  console.log(projectId);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>tailwindcss</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Day 178 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 09:36:10 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-178-of-learning-mern-stack-3dd7</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-178-of-learning-mern-stack-3dd7</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;Today marks &lt;strong&gt;Day 178&lt;/strong&gt; of my full-stack journey, and I’m officially kicking off a new major project: &lt;strong&gt;An AI-Powered Website Builder&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The goal is to turn simple user natural language prompts into responsive web applications instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ The Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Frontend:&lt;/strong&gt; React, TypeScript, Tailwind CSS&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Core Feature:&lt;/strong&gt; AI-driven prompt parsing to UI generation&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;UX focus:&lt;/strong&gt; Minimalist, high-contrast premium UI&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🖥️ Implementation Highlights (Home Page)
&lt;/h2&gt;

&lt;p&gt;Today I built the Landing Hero Section. The key focus was ensuring a robust, type-safe submission flow. &lt;/p&gt;

&lt;p&gt;Highlights:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript-driven Event Handling:&lt;/strong&gt; Using &lt;code&gt;React.FormEvent&lt;/code&gt; to type the submission handler.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State Orchestration:&lt;/strong&gt; Managing loading states for the AI request lifecycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guard Clauses:&lt;/strong&gt; Ensuring authentication and non-empty inputs before hitting the API.&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
const onSubmitHandler = async (e: React.FormEvent) =&amp;gt; {
  e.preventDefault();
  if (!session?.user) return toast.error("Please sign in");
  setLoading(true);
  // Simulate AI API Call
  const { data } = await api.post("/api/user/project", { initial_prompt: input });
  navigate(`/projects/${data.projectId}`);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>ai</category>
      <category>programming</category>
    </item>
    <item>
      <title>Day 177 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 09:10:28 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-177-of-learning-mern-stack-3ac5</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-177-of-learning-mern-stack-3ac5</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 177&lt;/strong&gt; of my full-stack engineering track! Today, I explored &lt;strong&gt;TypeScript Object Modeling&lt;/strong&gt;: &lt;strong&gt;Type Aliases vs Interfaces&lt;/strong&gt;, &lt;strong&gt;Class Implementation Constraints&lt;/strong&gt;, &lt;strong&gt;Intersection Types (&lt;code&gt;&amp;amp;&lt;/code&gt;)&lt;/strong&gt;, &lt;strong&gt;Optional Fields (&lt;code&gt;?&lt;/code&gt;)&lt;/strong&gt;, and &lt;strong&gt;&lt;code&gt;readonly&lt;/code&gt; Immutability&lt;/strong&gt;! 📘⚡&lt;/p&gt;

&lt;p&gt;Here is a breakdown of how these typing rules dictate contract enforcement across TypeScript codebases.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: Object Contracts &amp;amp; Type Mechanics
&lt;/h2&gt;

&lt;p&gt;As captured in my code editor setup (&lt;strong&gt;&lt;code&gt;index.ts&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Interface Implementation in Classes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Classes require statically known contracts. While union types cannot be directly implemented by classes, &lt;code&gt;interfaces&lt;/code&gt; handle OOP structure cleanly:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
  interface Cupsize {
    size: "small" | "large";
  }

  class Chai implements Cupsize {
    size: "small" | "large" = "small";
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Day 176 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 07:38:56 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-176-of-learning-mern-stack-1b88</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-176-of-learning-mern-stack-1b88</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 176&lt;/strong&gt; of my full-stack engineering track! Today, I explored advanced type-safety mechanics in &lt;strong&gt;TypeScript&lt;/strong&gt;: &lt;strong&gt;Type Assertions (&lt;code&gt;as&lt;/code&gt;)&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;unknown&lt;/code&gt; vs &lt;code&gt;any&lt;/code&gt;&lt;/strong&gt;, and the &lt;strong&gt;&lt;code&gt;never&lt;/code&gt; type for exhaustive checks&lt;/strong&gt;! 📘⚡&lt;/p&gt;

&lt;p&gt;Here is how these strict type features make applications bulletproof against runtime failures.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: Advanced TypeScript Typing
&lt;/h2&gt;

&lt;p&gt;As captured in my code editor setup (&lt;strong&gt;&lt;code&gt;index.ts&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Type Assertions (&lt;code&gt;as&lt;/code&gt; Keyword)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Overrode default compiler inference when working with DOM elements and &lt;code&gt;JSON.parse()&lt;/code&gt; results:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
  const element = document.querySelector('Element') as HTMLInputElement;
  const bookObject = JSON.parse(stringBook) as Book;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Day 175 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 07:34:12 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-175-of-learning-mern-stack-4pc2</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-175-of-learning-mern-stack-4pc2</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 175&lt;/strong&gt; of my full-stack engineering track! Today, I explored one of the most essential features for writing safe dynamic code in &lt;strong&gt;TypeScript&lt;/strong&gt;: &lt;strong&gt;Type Narrowing &amp;amp; Type Guards&lt;/strong&gt;! 📘⚡&lt;/p&gt;

&lt;p&gt;Type narrowing allows TypeScript to deduce specific types within conditional code blocks, eliminating type ambiguity and runtime crashes.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: Type Narrowing Techniques
&lt;/h2&gt;

&lt;p&gt;As captured in my code editor setup (&lt;strong&gt;&lt;code&gt;index.ts&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Discriminated Unions (Tagged Unions)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Utilized a common literal discriminator property (&lt;code&gt;type&lt;/code&gt;) across distinct object types to cleanly handle polymorphic structures via &lt;code&gt;switch&lt;/code&gt; statements:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
  type MasalaChai = { type: 'Masala', spicelevel: number };
  type GingerChai = { type: 'Ginger', amount: number };
  type ElaichiChai = { type: 'Elaichi', packet: number };

  type Chai = MasalaChai | GingerChai | ElaichiChai;

  const makeChai = (order: Chai) =&amp;gt; {
    switch (order.type) {
      case 'Elaichi': return "Elaichi Wali Chai";
      case 'Ginger': return "Ginger Wali Chai";
      case 'Masala': return "Masala Wali Chai";
    }
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Day 174 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 07:30:27 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-174-of-learning-mern-stack-42m6</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-174-of-learning-mern-stack-42m6</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 174&lt;/strong&gt; of my full-stack engineering journey! Today, I explored &lt;strong&gt;Union Types&lt;/strong&gt;, &lt;strong&gt;Literal Types&lt;/strong&gt;, and the dangers of implicit &lt;strong&gt;&lt;code&gt;any&lt;/code&gt;&lt;/strong&gt; in &lt;strong&gt;TypeScript&lt;/strong&gt;! 📘⚡&lt;/p&gt;

&lt;p&gt;Here is how flexible typing and strict status constraints work under the hood.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: Unions, Literals &amp;amp; &lt;code&gt;any&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;As captured in my code editor setup (&lt;strong&gt;&lt;code&gt;index.ts&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Flexible Union Types &amp;amp; Strict String Literals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Used bitwise OR operator syntax (&lt;code&gt;|&lt;/code&gt;) to allow multi-type assignments or restrict variables to fixed values:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
  let subs: number | string = 10;
  subs = '10M'; // Valid reassignment

  let apiReq: 'pending' | 'success' | 'error' = 'pending'; // Restricts allowed status values
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Day 173 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 07:25:32 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-173-of-learning-mern-stack-36b5</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-173-of-learning-mern-stack-36b5</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 173&lt;/strong&gt; of my full-stack engineering track! Today, I explored one of the core mechanisms that make &lt;strong&gt;TypeScript&lt;/strong&gt; powerful and developer-friendly: &lt;strong&gt;Type Inference vs. Type Annotations&lt;/strong&gt;! 📘⚡&lt;/p&gt;

&lt;p&gt;Understanding when to let the TypeScript compiler infer types automatically versus declaring them explicitly makes codebases cleaner and more maintainable.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: Inference vs. Annotations
&lt;/h2&gt;

&lt;p&gt;As captured in my code editor setup (&lt;strong&gt;&lt;code&gt;index.ts&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Type Inference (Implicit Typing)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;TypeScript automatically determines the variable type based on its initial assigned value:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
  let drink = "Chai peyo"; // Inferenced as type string
  // drink = 0; // Error: Type 'number' is not assignable to type 'string'.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Day 172 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sun, 16 Aug 2026 07:21:05 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-172-of-learning-mern-stack-42f5</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-172-of-learning-mern-stack-42f5</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 172&lt;/strong&gt; of my full-stack engineering track! After wrapping up my MERN stack Chat Application, today marks the start of my &lt;strong&gt;TypeScript&lt;/strong&gt; journey! 📘⚡&lt;/p&gt;

&lt;p&gt;I explored the core fundamentals of type safety, type annotations, and basic primitive types (&lt;code&gt;string&lt;/code&gt;, &lt;code&gt;number&lt;/code&gt;, &lt;code&gt;boolean&lt;/code&gt;).&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: Primitive Types &amp;amp; Function Contracts
&lt;/h2&gt;

&lt;p&gt;As captured in my code editor setup (&lt;strong&gt;&lt;code&gt;index.ts&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Function Parameter &amp;amp; Return Annotations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Defined strict type contracts on function inputs and return values to prevent runtime type mismatch bugs:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
  function greet(name: string): string {
    return `Hello ${name}`;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>typescript</category>
      <category>types</category>
    </item>
    <item>
      <title>Day 171 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sat, 01 Aug 2026 07:49:22 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-171-of-learning-mern-stack-3jkc</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-171-of-learning-mern-stack-3jkc</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 171&lt;/strong&gt; of my full-stack web development journey, and I am thrilled to announce that &lt;strong&gt;QuickChat (MERN Stack Real-Time Chat App)&lt;/strong&gt; is officially complete! 🎉🚀&lt;/p&gt;

&lt;p&gt;Today, I finalized the last key security layer: &lt;strong&gt;JWT Authentication &amp;amp; Route Protection Middleware&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: JWT Route Security
&lt;/h2&gt;

&lt;p&gt;As captured in my implementation snapshots (&lt;strong&gt;&lt;code&gt;auth.js&lt;/code&gt; &amp;amp; &lt;code&gt;utils.js&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Token Signature Utility (&lt;code&gt;utils.js&lt;/code&gt;)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Configured a centralized token generator helper signing payload &lt;code&gt;userId&lt;/code&gt; parameters using environment secrets:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
javascript
  const generateToken = (userId) =&amp;gt; {
    return jwt.sign({ userId }, process.env.JWT_SECRET);
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>mongodb</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Day 170 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sat, 01 Aug 2026 07:34:21 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-170-of-learning-mern-stack-53ck</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-170-of-learning-mern-stack-53ck</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 170&lt;/strong&gt; of my full-stack engineering track! Today, I designed and implemented the backend message retrieval and chat history processing endpoints (&lt;strong&gt;&lt;code&gt;getUserforSidebar&lt;/code&gt;&lt;/strong&gt; &amp;amp; &lt;strong&gt;&lt;code&gt;getMessages&lt;/code&gt;&lt;/strong&gt;) for &lt;strong&gt;QuickChat&lt;/strong&gt; using &lt;strong&gt;Node.js, Express, and MongoDB&lt;/strong&gt;! ⚙️💬&lt;/p&gt;

&lt;p&gt;Here is how I structured the database queries for chat retrieval and read receipts.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: Message Fetching &amp;amp; Unseen Counters
&lt;/h2&gt;

&lt;p&gt;As captured in my implementation snapshots (&lt;strong&gt;&lt;code&gt;messageController.js&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Dynamic User Discovery &amp;amp; Parallel Unseen Counting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Filtered out the currently logged-in user using Mongoose &lt;code&gt;$ne&lt;/code&gt; operator while stripping out password projections.&lt;/li&gt;
&lt;li&gt;Used &lt;code&gt;Promise.all&lt;/code&gt; alongside &lt;code&gt;map&lt;/code&gt; iterations to asynchronously gather unread message counts per user card:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
javascript
  const filteredUser = await user.find({ _id: { $ne: userId } }).select("-password");

  const promise = filteredUser.map(async (user) =&amp;gt; {
    const messages = await message.find({ senderId: user._id, receiverId: userId, seen: false });
    if (messages.length &amp;gt; 0) {
      unseenMessages[user._id] = messages.length;
    }
  });
  await Promise.all(promise);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>mongodb</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Day 169 of Learning MERN Stack</title>
      <dc:creator>Ali Hamza</dc:creator>
      <pubDate>Sat, 01 Aug 2026 07:30:31 +0000</pubDate>
      <link>https://dev.to/ali_hamza_589ec7b3eb6688d/day-169-of-learning-mern-stack-le2</link>
      <guid>https://dev.to/ali_hamza_589ec7b3eb6688d/day-169-of-learning-mern-stack-le2</guid>
      <description>&lt;p&gt;Hello Dev Community! 👋&lt;/p&gt;

&lt;p&gt;It is officially &lt;strong&gt;Day 169&lt;/strong&gt; of my full-stack engineering track! Today, I built the core messaging dispatch engine (&lt;strong&gt;&lt;code&gt;sendMessage&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;markMessagesAsSeen&lt;/code&gt;&lt;/strong&gt;) for my real-time chat application, &lt;strong&gt;QuickChat&lt;/strong&gt;! 💬⚡&lt;/p&gt;

&lt;p&gt;This module ties together database persistence, media hosting, and WebSocket streaming into a single controller execution flow.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Technical Breakdown: Messaging Controller Architecture
&lt;/h2&gt;

&lt;p&gt;As captured in my implementation snapshots (&lt;strong&gt;&lt;code&gt;messageController.js&lt;/code&gt;&lt;/strong&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Cloudinary Integration &amp;amp; Mongoose Persistence
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Checked incoming payloads for image attachments to upload directly via Cloudinary SDK before persisting document records into MongoDB:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
javascript
  if (image) {
    const uploadResponse = await cloudinary.uploader.upload(image);
    imageURL = uploadResponse.secure_url;
  }
  const newMessage = await message.create({
    senderId,
    receiverId,
    text,
    image: imageURL
  }); const receiverSocketId = getReceiverSocketId(receiverId);
if (receiverSocketId) {
  getIO().to(receiverSocketId).emit('newMessage', newMessage);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>mongodb</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
