<?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: Ilyas Abdisalam</title>
    <description>The latest articles on DEV Community by Ilyas Abdisalam (@ilyasgaraad).</description>
    <link>https://dev.to/ilyasgaraad</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%2F3268683%2F07bea61f-ab91-4cf2-8091-06dd67a44c8a.jpeg</url>
      <title>DEV Community: Ilyas Abdisalam</title>
      <link>https://dev.to/ilyasgaraad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ilyasgaraad"/>
    <language>en</language>
    <item>
      <title>The Future of Backend Development: How AI, Edge Computing, and Serverless Are Reshaping the Modern API Stack</title>
      <dc:creator>Ilyas Abdisalam</dc:creator>
      <pubDate>Sat, 08 Nov 2025 17:00:31 +0000</pubDate>
      <link>https://dev.to/ilyasgaraad/the-future-of-backend-development-how-ai-edge-computing-and-serverless-are-reshaping-the-modern-1ppg</link>
      <guid>https://dev.to/ilyasgaraad/the-future-of-backend-development-how-ai-edge-computing-and-serverless-are-reshaping-the-modern-1ppg</guid>
      <description>&lt;h1&gt;
  
  
  1. Introduction: The New Era of Backend Development
&lt;/h1&gt;

&lt;p&gt;Backend development has evolved through several defining stages. In the early days, most applications were built on monolithic servers—large, tightly coupled systems that handled everything from business logic to database management in one place. As projects grew more complex, developers shifted toward microservices, splitting applications into smaller, independent components that could be developed and deployed separately. This change improved scalability and made teams more agile. The next big leap came with cloud functions and serverless architectures, where developers could deploy individual functions on-demand without worrying about server maintenance or scaling.&lt;/p&gt;

&lt;p&gt;Now, a new transformation is underway. With artificial intelligence reshaping how systems operate, one question stands out:&lt;/p&gt;

&lt;p&gt;What’s next for backend developers in the AI-driven era?&lt;/p&gt;

&lt;h1&gt;
  
  
  2. AI in the Backend: From Automation to Smart APIs
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Discuss how generative AI is changing backend design:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Auto-documentation (e.g., Swagger generated via AI).&lt;/li&gt;
&lt;li&gt;Code assistants (GitHub Copilot, ChatGPT o1 models) reducing boilerplate.&lt;/li&gt;
&lt;li&gt;AI middleware: smart recommendation APIs, real-time personalization, etc.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Example: an Express middleware that uses an AI model to classify incoming requests (e.g., spam detection or fraud scoring).&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  3. Serverless Computing: From Deployment to Automation
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Explain how developers now skip full-stack setup and use:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;AWS Lambda, Google Cloud Functions, or Vercel Functions.&lt;/li&gt;
&lt;li&gt;Benefits: scalability, cost-efficiency, no manual server management.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Show a short code example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.openai.com/...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Mention pitfalls (cold starts, vendor lock-in) and strategies to mitigate them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  4. Edge Computing: Bringing APIs Closer to Users
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Explain what edge computing is (running code near the user’s location).&lt;/li&gt;
&lt;li&gt;Show how frameworks like Cloudflare Workers or Vercel Edge Functions improve response times.&lt;/li&gt;
&lt;li&gt;Use a comparison diagram (traditional vs edge requests).&lt;/li&gt;
&lt;li&gt;Example: “An Istanbul user’s API call no longer travels to Virginia—runs on a data center nearby.”&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  5. The Convergence: AI + Serverless + Edge
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Show how modern startups combine all three:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Serverless for compute.&lt;/li&gt;
&lt;li&gt;Edge for latency.&lt;/li&gt;
&lt;li&gt;AI for intelligence&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Example workflow: user uploads data → serverless triggers AI model → result served from edge cache.&lt;/li&gt;
&lt;li&gt;Mention open-source projects like LangChain, Supabase Edge Functions, Vercel AI SDK, or Cloudflare Workers AI.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  6. Security and API Evolution
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Explain how JWT and OAuth2 remain key but new models (like fine-grained API keys and AI-auth layers) are emerging.&lt;/li&gt;
&lt;li&gt;Mention how rate limiting, bot detection, and zero-trust architectures are blending with AI.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  7. Tools to Watch in 2025
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Vercel AI SDK&lt;/li&gt;
&lt;li&gt;Cloudflare Workers AI&lt;/li&gt;
&lt;li&gt;Supabase Edge Functions&lt;/li&gt;
&lt;li&gt;LangGraph / LangServe for AI pipelines&lt;/li&gt;
&lt;li&gt;Bun.js (fast Node.js alternative)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  8. Practical Example
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Create a short end-to-end demo idea:
“An intelligent API that detects spam reviews using OpenAI and runs on Vercel Edge Functions.”&lt;/li&gt;
&lt;li&gt;You can show setup, code, and how latency improves — readers love this blend of concept + code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  9. The Developer Mindset Shift
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Discuss how backend developers must now think like system architects—balancing AI, data, performance, and user experience.&lt;/li&gt;
&lt;li&gt;Emphasize the importance of learning cloud tools, AI integration, and distributed systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  10. Conclusion: The Backend Developer of 2025
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Summarize the transition: from REST APIs to intelligent, distributed, self-healing systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Encourage readers to learn incrementally:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Build a REST API.&lt;/li&gt;
&lt;li&gt;Deploy serverless.&lt;/li&gt;
&lt;li&gt;Experiment with AI integrations.&lt;/li&gt;
&lt;li&gt;Move toward edge deployments.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Close with an inspiring note:
“In 2025, backend development is not about managing servers—it’s about designing intelligence at scale.”&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>backend</category>
      <category>ai</category>
      <category>serverless</category>
      <category>api</category>
    </item>
    <item>
      <title>Understanding Deadlocks in Multithreaded Systems</title>
      <dc:creator>Ilyas Abdisalam</dc:creator>
      <pubDate>Thu, 26 Jun 2025 21:17:24 +0000</pubDate>
      <link>https://dev.to/ilyasgaraad/understanding-deadlocks-in-multithreaded-systems-14ni</link>
      <guid>https://dev.to/ilyasgaraad/understanding-deadlocks-in-multithreaded-systems-14ni</guid>
      <description>&lt;p&gt;Deadlocks are one of the most notorious issues in multithreaded programming. They freeze applications, frustrate developers, and often require intricate debugging. In this guide, we’ll break down deadlocks into digestible parts—with code examples, visuals, and solutions.  &lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Deadlock?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;deadlock&lt;/strong&gt; occurs when two or more threads are blocked forever, each waiting for the other to release a resource.  &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%2Fn5g85izh8uw2h8k6ku8y.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%2Fn5g85izh8uw2h8k6ku8y.png" alt="Deadlocks" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The 4 Necessary Conditions for Deadlocks
&lt;/h3&gt;

&lt;p&gt;For a deadlock to happen, &lt;strong&gt;all four&lt;/strong&gt; of these conditions must hold:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Mutual Exclusion&lt;/strong&gt;: Only one thread can hold a resource at a time.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hold and Wait&lt;/strong&gt;: A thread holds a resource while waiting for another.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Preemption&lt;/strong&gt;: Resources cannot be forcibly taken from threads.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Circular Wait&lt;/strong&gt;: Threads form a cycle waiting for each other.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  A Classic Deadlock Example in Code
&lt;/h2&gt;

&lt;p&gt;Here’s a simple Java deadlock scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class DeadlockDemo {  
    private static final Object lock1 = new Object();  
    private static final Object lock2 = new Object();  

    public static void main(String[] args) {  
        Thread threadA = new Thread(() -&amp;gt; {  
            synchronized (lock1) {  
                System.out.println("Thread A: Holding lock 1...");  
                try { Thread.sleep(100); } catch (InterruptedException e) {}  
                synchronized (lock2) {  
                    System.out.println("Thread A: Acquired lock 2!");  
                }  
            }  
        });  

        Thread threadB = new Thread(() -&amp;gt; {  
            synchronized (lock2) {  
                System.out.println("Thread B: Holding lock 2...");  
                synchronized (lock1) {  
                    System.out.println("Thread B: Acquired lock 1!");  
                }  
            }  
        });  

        threadA.start();  
        threadB.start();  
    }  
}  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output Analysis
&lt;/h3&gt;

&lt;p&gt;When you run this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Both threads will print their first message ("Holding lock...").&lt;/li&gt;
&lt;li&gt;Neither will progress further—deadlock achieved!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Detect Deadlocks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Tools &amp;amp; Techniques
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Example Tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Thread Dump&lt;/td&gt;
&lt;td&gt;Analyzes thread states and locks.&lt;/td&gt;
&lt;td&gt;jstack  (Java)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Static Analysis&lt;/td&gt;
&lt;td&gt;Code reviews for circular waits.&lt;/td&gt;
&lt;td&gt;SonarQube&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runtime Monitoring&lt;/td&gt;
&lt;td&gt;Alerts on long-held locks.&lt;/td&gt;
&lt;td&gt;VisualVM&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Preventing Deadlocks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.Lock Ordering
&lt;/h3&gt;

&lt;p&gt;Always acquire locks in a consistent global order (e.g., always lock1 before lock2).&lt;/p&gt;

&lt;h2&gt;
  
  
  2.Timeouts
&lt;/h2&gt;

&lt;p&gt;Use tryLock(timeout) to avoid indefinite waits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (lock1.tryLock(100, TimeUnit.MILLISECONDS)) {  
    // Proceed if lock acquired  
}  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.Deadlock Detection Algorithms
&lt;/h3&gt;

&lt;p&gt;Advanced systems (e.g., databases) use wait-for graphs to detect cycles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;p&gt;✅ Deadlocks require all 4 conditions—break any one to prevent them.&lt;br&gt;
✅ Tooling (thread dumps, analyzers) is critical for debugging.&lt;br&gt;
✅ Prevention &amp;gt; Cure: Design systems to avoid circular waits.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>multithreading</category>
      <category>softwareengineering</category>
      <category>deadlocks</category>
    </item>
    <item>
      <title>Prevent API Abuse with Rate Limiting in Express.js</title>
      <dc:creator>Ilyas Abdisalam</dc:creator>
      <pubDate>Sat, 21 Jun 2025 17:10:57 +0000</pubDate>
      <link>https://dev.to/ilyasgaraad/prevent-api-abuse-with-rate-limiting-in-expressjs-28lf</link>
      <guid>https://dev.to/ilyasgaraad/prevent-api-abuse-with-rate-limiting-in-expressjs-28lf</guid>
      <description>&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;As your API grows in popularity, it's essential to protect it from overuse and abuse. One of the simplest and most effective strategies is rate limiting, which controls how many requests a user can make to your API in a given time window.&lt;/p&gt;

&lt;p&gt;This tutorial will walk you through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What rate limiting is&lt;/li&gt;
&lt;li&gt;Why it's important&lt;/li&gt;
&lt;li&gt;How to implement it in an Express.js application&lt;/li&gt;
&lt;li&gt;Best practices and options for production systems&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. What is Rate Limiting?
&lt;/h2&gt;

&lt;p&gt;Rate limiting sets a restriction on how many requests a client (usually identified by IP address or user token) can make in a given period.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Max 100 requests per user per 15 minutes&lt;/li&gt;
&lt;li&gt;Only 10 login attempts per hour&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔒 Why Use Rate Limiting?
&lt;/h3&gt;

&lt;p&gt;✅ Prevents DDoS attacks&lt;/p&gt;

&lt;p&gt;✅ Stops brute-force login attempts&lt;/p&gt;

&lt;p&gt;✅ Protects backend resources&lt;/p&gt;

&lt;p&gt;✅ Creates fair usage among users&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Setting Up Express Rate Limiting
&lt;/h2&gt;

&lt;p&gt;We'll use the open-source express-rate-limit middleware to set up basic limits.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Project Setup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir express-rate-limit-demo &amp;amp;&amp;amp; cd express-rate-limit-demo
npm init -y
npm install express express-rate-limit dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.2 Basic Server Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app.js
const express = require('express');
const rateLimit = require('express-rate-limit');
const app = express();
const PORT = process.env.PORT || 3000;

// Apply to all requests
const limiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 100, // Limit each IP to 100 requests per windowMs
  message: 'Too many requests from this IP, please try again later.'
});

app.use(limiter);

app.get('/', (req, res) =&amp;gt; {
  res.send('Hello, this is a rate-limited API.');
});

app.listen(PORT, () =&amp;gt; console.log(`Server running on port ${PORT}`));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Advanced Use Cases
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 Rate Limit Specific Routes Only
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const loginLimiter = rateLimit({
  windowMs: 60 * 60 * 1000, // 1 hour
  max: 5,
  message: 'Too many login attempts. Try again after an hour.'
});

app.post('/login', loginLimiter, (req, res) =&amp;gt; {
  res.send('Login endpoint.');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.2 Use a Custom Handler
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const limiterWithHandler = rateLimit({
  windowMs: 15 * 60 * 1000,
  max: 10,
  handler: (req, res) =&amp;gt; {
    res.status(429).json({
      status: 'fail',
      message: 'Rate limit exceeded. Please try again later.'
    });
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Visualization: Rate Limiting Flow
&lt;/h2&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%2F98g2dplavudeieniv6ty.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%2F98g2dplavudeieniv6ty.png" alt="Rate limiting flow " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Best Practices
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Practice&lt;/th&gt;
&lt;th&gt;Reason&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Limit sensitive endpoints&lt;/td&gt;
&lt;td&gt;Login, signup, and search are attack targets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Adjust limits per user role&lt;/td&gt;
&lt;td&gt;Admins may need higher thresholds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use distributed stores (Redis)&lt;/td&gt;
&lt;td&gt;For multi-server rate limiting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Return informative error messages&lt;/td&gt;
&lt;td&gt;Helps users understand what's happening&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Log rate-limited requests&lt;/td&gt;
&lt;td&gt;Useful for security auditing and analytics&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  7. Bonus: Rate Limiting with Redis (for production)
&lt;/h2&gt;

&lt;p&gt;In production, especially with multiple servers or containers, you need to share rate-limit state. This is usually done with Redis.&lt;/p&gt;

&lt;p&gt;You can use the package:&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 rate-limit-redis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then use it as the store:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const RedisStore = require('rate-limit-redis');
const limiter = rateLimit({
  store: new RedisStore({
    sendCommand: (...args) =&amp;gt; redisClient.call(...args)
  }),
  windowMs: 60 * 1000,
  max: 100
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8. Conclusion
&lt;/h2&gt;

&lt;p&gt;Rate limiting is a simple but powerful tool for protecting your API. In just a few lines of code, you can dramatically reduce abuse, make your services more stable, and provide a better experience for your users.&lt;/p&gt;

&lt;p&gt;You’ve now learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What rate limiting is and why it matters&lt;/li&gt;
&lt;li&gt;How to implement it with express-rate-limit&lt;/li&gt;
&lt;li&gt;Best practices and how to scale with Redis&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Secure Your REST API with JWT Authentication (Beginner Friendly)</title>
      <dc:creator>Ilyas Abdisalam</dc:creator>
      <pubDate>Fri, 20 Jun 2025 14:04:15 +0000</pubDate>
      <link>https://dev.to/ilyasgaraad/secure-your-rest-api-with-jwt-authentication-beginner-friendly-2e5f</link>
      <guid>https://dev.to/ilyasgaraad/secure-your-rest-api-with-jwt-authentication-beginner-friendly-2e5f</guid>
      <description>&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;As APIs become more central to modern web apps, securing them is critical. One common and powerful method is JWT (JSON Web Token) authentication. It allows secure, stateless communication between client and server.&lt;/p&gt;

&lt;p&gt;In this guide, we’ll walk through the core concepts, the authentication flow, and how to implement JWT in a Node.js + Express API.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What is JWT?
&lt;/h2&gt;

&lt;p&gt;JWT (JSON Web Token) is a compact, URL-safe way of representing claims between two parties. It’s widely used for authentication.&lt;br&gt;
A JWT has three parts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HEADER.PAYLOAD.SIGNATURE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example Token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTY3Nzg0NTM1Nn0.vPObNvSaNfrqzuhRRYtNnmlbRrFYP7oowC_NWkpiW1k
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Header&lt;/td&gt;
&lt;td&gt;Algorithm + Token type&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Payload&lt;/td&gt;
&lt;td&gt;Claims (user ID, role, etc.)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Signature&lt;/td&gt;
&lt;td&gt;Verifies token integrity (signed)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  3. JWT Authentication Flow
&lt;/h2&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%2Ffeheyz0t9nagdu5aqmne.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%2Ffeheyz0t9nagdu5aqmne.png" alt="JWT Authentication Flow" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Example Project Structure (Node.js + Express)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;project/
├── controllers/
│   └── auth.js
├── middleware/
│   └── authMiddleware.js
├── routes/
│   └── authRoutes.js
├── app.js
├── .env
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Code Breakdown
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 Install Required Packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install express jsonwebtoken dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.2 Generate Token (Login Route)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const jwt = require('jsonwebtoken');
const SECRET = process.env.JWT_SECRET;

function login(req, res) {
  const user = { id: 1, username: 'ilyas' }; // dummy user
  const token = jwt.sign({ userId: user.id }, SECRET, { expiresIn: '1h' });
  res.json({ token });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.3 Protect Routes with Middleware
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function verifyToken(req, res, next) {
  const token = req.headers['authorization']?.split(' ')[1];
  if (!token) return res.sendStatus(401);

  jwt.verify(token, process.env.JWT_SECRET, (err, decoded) =&amp;gt; {
    if (err) return res.sendStatus(403);
    req.userId = decoded.userId;
    next();
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.4 Secure Endpoint Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/profile', verifyToken, (req, res) =&amp;gt; {
  res.send(`This is a protected route for user ${req.userId}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Best Practices for JWT
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tip&lt;/th&gt;
&lt;th&gt;Why It Matters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Use short expiration times&lt;/td&gt;
&lt;td&gt;Limits damage from stolen tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Store tokens securely&lt;/td&gt;
&lt;td&gt;Avoid localStorage for sensitive data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rotate tokens periodically&lt;/td&gt;
&lt;td&gt;Increase security&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Never store JWT secret in code&lt;/td&gt;
&lt;td&gt;Use environment variables&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  7. Conclusion
&lt;/h2&gt;

&lt;p&gt;JWT is a powerful way to secure RESTful APIs in a stateless and scalable manner. You now understand the structure, flow, and implementation of JWT authentication in a Node.js Express app.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>authjs</category>
      <category>jwt</category>
    </item>
    <item>
      <title>Understanding RESTful APIs</title>
      <dc:creator>Ilyas Abdisalam</dc:creator>
      <pubDate>Thu, 19 Jun 2025 16:10:04 +0000</pubDate>
      <link>https://dev.to/ilyasgaraad/understanding-restful-apis-18ni</link>
      <guid>https://dev.to/ilyasgaraad/understanding-restful-apis-18ni</guid>
      <description>&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%2F4ozzr401n6wr2layojsk.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%2F4ozzr401n6wr2layojsk.png" alt="RESTful API request flow diagram" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;In modern software development, APIs (Application Programming Interfaces) allow different software systems to communicate with each other. One of the most popular types of APIs is the RESTful API, which follows the principles of REST (Representational State Transfer).&lt;/p&gt;

&lt;p&gt;A RESTful API is stateless, resource-based, and communicates over HTTP. It's widely used in web applications, mobile apps, and even IoT devices.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Core Concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 Client and Server
&lt;/h3&gt;

&lt;p&gt;In REST architecture, the client sends a request, and the server processes it and returns a response. They are independent: the client doesn't need to know how the server stores data, and the server doesn't need to know how the client uses it.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.2 Resources and URIs
&lt;/h3&gt;

&lt;p&gt;A resource is anything that can be named and manipulated via the API, such as a user, a book, or a product. Each resource is identified by a URI (Uniform Resource Identifier).&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /books/1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This retrieves the book with ID 1.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 HTTP Methods
&lt;/h3&gt;

&lt;p&gt;RESTful APIs use HTTP methods to define actions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;Read&lt;/td&gt;
&lt;td&gt;Retrieve a resource&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;Create&lt;/td&gt;
&lt;td&gt;Add a new resource&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PUT&lt;/td&gt;
&lt;td&gt;Update&lt;/td&gt;
&lt;td&gt;Replace a resource&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PATCH&lt;/td&gt;
&lt;td&gt;Partial Update&lt;/td&gt;
&lt;td&gt;Update part of a resource&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DELETE&lt;/td&gt;
&lt;td&gt;Delete&lt;/td&gt;
&lt;td&gt;Remove a resource&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  2.4 HTTP Status Codes
&lt;/h3&gt;

&lt;p&gt;Responses include status codes to indicate success or failure:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Code&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;Ok&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;201&lt;/td&gt;
&lt;td&gt;Created&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;400&lt;/td&gt;
&lt;td&gt;Bad Request&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;401&lt;/td&gt;
&lt;td&gt;Unauthorized&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;404&lt;/td&gt;
&lt;td&gt;Not Found&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;td&gt;Internal Server Error&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  3. Example Use Case: Book API
&lt;/h2&gt;

&lt;p&gt;Suppose we want to build a RESTful API to manage books in a library system. Here are the main endpoints:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;/books&lt;/td&gt;
&lt;td&gt;Get a list of books&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;/books/{id}&lt;/td&gt;
&lt;td&gt;Get details of a specific book&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;/books&lt;/td&gt;
&lt;td&gt;Create a new book&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PUT&lt;/td&gt;
&lt;td&gt;/books/{id}&lt;/td&gt;
&lt;td&gt;Update a book completely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete&lt;/td&gt;
&lt;td&gt;/books/{id}&lt;/td&gt;
&lt;td&gt;Delete a book&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example JSON for creating a book (POST /books):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "title": "Clean Code",
  "author": "Geedi Osman",
  "year": 2008
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. How Requests and Responses Work
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 Request Structure
&lt;/h3&gt;

&lt;p&gt;A typical HTTP request includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Method (e.g., GET, POST)&lt;/li&gt;
&lt;li&gt;URL (e.g., /books/1)&lt;/li&gt;
&lt;li&gt;Headers (e.g., Content-Type, Authorization)&lt;/li&gt;
&lt;li&gt;Body (only for POST, PUT, PATCH)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4.2 Response Structure
&lt;/h3&gt;

&lt;p&gt;A response includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Status Code (e.g., 200 OK)&lt;/li&gt;
&lt;li&gt;Headers (e.g., Content-Type)&lt;/li&gt;
&lt;li&gt;Body (JSON or other format)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example Response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "id": 1,
  "title": "Clean Code",
  "author": "Geedi Osman",
  "year": 2008
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Best Practices for REST APIs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 Use Proper Status Codes
&lt;/h3&gt;

&lt;p&gt;Use 201 for resource creation, 404 for missing resources, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.2 Use JSON as the Default Format
&lt;/h3&gt;

&lt;p&gt;It's lightweight, readable, and widely supported.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.3 Implement Pagination for Large Results
&lt;/h3&gt;

&lt;p&gt;Example: /books?page=2&amp;amp;limit=10&lt;/p&gt;

&lt;h3&gt;
  
  
  5.4 Version Your API
&lt;/h3&gt;

&lt;p&gt;Example: /api/v1/books&lt;/p&gt;

&lt;h3&gt;
  
  
  5.5 Secure Your API
&lt;/h3&gt;

&lt;p&gt;Use authentication (e.g., JWT tokens), validate inputs, and enforce HTTPS.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Conclusion
&lt;/h2&gt;

&lt;p&gt;RESTful APIs are a foundational part of web development. By understanding the principles behind REST—such as statelessness, resource orientation, and HTTP standards—you can build and consume APIs effectively.&lt;/p&gt;

&lt;p&gt;To continue learning, explore tools like Postman (for testing APIs), Swagger (for documenting APIs), and frameworks like Express (Node.js) or Flask (Python) to build your own REST APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. What’s Next?
&lt;/h2&gt;

&lt;p&gt;If you understood this guide, try building a simple REST API using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js with Express (&lt;a href="https://expressjs.com/" rel="noopener noreferrer"&gt;https://expressjs.com/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Python with Flask (&lt;a href="https://flask.palletsprojects.com/" rel="noopener noreferrer"&gt;https://flask.palletsprojects.com/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Use Postman to test your endpoints&lt;/li&gt;
&lt;li&gt;Document your own mini API and share it online!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>restful</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>✅ How to Use MongoDB with Express.js</title>
      <dc:creator>Ilyas Abdisalam</dc:creator>
      <pubDate>Tue, 17 Jun 2025 16:42:22 +0000</pubDate>
      <link>https://dev.to/ilyasgaraad/how-to-use-mongodb-with-expressjs-2lan</link>
      <guid>https://dev.to/ilyasgaraad/how-to-use-mongodb-with-expressjs-2lan</guid>
      <description>&lt;h2&gt;
  
  
  📘 Overview
&lt;/h2&gt;

&lt;p&gt;This guide shows you how to connect a MongoDB database to an Express.js application using the official mongodb driver. This is useful for developers building full-stack JavaScript applications that need to store and retrieve data.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before you begin, make sure you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js and npm installed&lt;/li&gt;
&lt;li&gt;MongoDB installed locally or a MongoDB Atlas cloud database&lt;/li&gt;
&lt;li&gt;Basic knowledge of JavaScript and Express.js&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ Step 1: Create a New Express App
&lt;/h2&gt;

&lt;p&gt;A. Create a new project folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir express-mongo-app
cd express-mongo-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;B. Initialize a Node.js project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
npm install express mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C. Create an index.js file with this boilerplate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// CommonJS (used in Node.js by default, not ES6 module)
const express = require('express');
const app = express();
const port = 3000;

app.use(express.json());

app.listen(port, () =&amp;gt; {
  console.log(`Server is running on http://localhost:${port}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🔌 Step 2: Connect to MongoDB
&lt;/h2&gt;

&lt;p&gt;A. At the top of index.js, import the MongoDB client:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;B. Define your connection URL and database name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const uri = 'mongodb://localhost:27017'; // Replace with your MongoDB Atlas URI if using cloud
const client = new MongoClient(uri);
const dbName = 'myDatabase';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C. Create an async function to connect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function run() {
  try {
    await client.connect();
    console.log('Connected successfully to MongoDB');

    const db = client.db(dbName);
    const collection = db.collection('users');

    // Sample route to insert a user
    app.post('/users', async (req, res) =&amp;gt; {
      const user = req.body;
      const result = await collection.insertOne(user);
      res.send(result);
    });

    // Sample route to get all users
    app.get('/users', async (req, res) =&amp;gt; {
      const users = await collection.find({}).toArray();
      res.send(users);
    });

  } catch (err) {
    console.error(err);
  }
}

run();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ▶️ Step 3: Test the App
&lt;/h2&gt;

&lt;p&gt;A. Start the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;B. Use Postman or curl to test endpoints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Insert a user:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X POST http://localhost:3000/users -H "Content-Type: application/json" -d '{"name": "Mohamed", "email": "Mohamed@gmail.com"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Get all users:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl http://localhost:3000/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🧼 Step 4: Clean Up and Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Store your MongoDB URI in an environment variable (e.g., .env)&lt;/li&gt;
&lt;li&gt;Handle connection errors and cleanup with process.on('SIGINT')&lt;/li&gt;
&lt;li&gt;Use async/await consistently for clarity&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ✅ Summary
&lt;/h2&gt;

&lt;p&gt;You’ve learned how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set up a Node.js + Express.js app&lt;/li&gt;
&lt;li&gt;Connect to MongoDB (local or Atlas)&lt;/li&gt;
&lt;li&gt;Insert and retrieve data with API endpoints&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>mongodb</category>
      <category>express</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Deploy a Node.js App to Vercel</title>
      <dc:creator>Ilyas Abdisalam</dc:creator>
      <pubDate>Mon, 16 Jun 2025 16:02:22 +0000</pubDate>
      <link>https://dev.to/ilyasgaraad/how-to-deploy-a-nodejs-app-to-vercel-3ke9</link>
      <guid>https://dev.to/ilyasgaraad/how-to-deploy-a-nodejs-app-to-vercel-3ke9</guid>
      <description>&lt;p&gt;This tutorial will show you how to deploy a simple Node.js (Express) app to &lt;a href="https://vercel.com" rel="noopener noreferrer"&gt;Vercel&lt;/a&gt;. It’s perfect for beginners who want to get their API online fast — without worrying about infrastructure.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧰 Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before you start, make sure you have the following installed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Node.js and npm on your system
&lt;/li&gt;
&lt;li&gt;✅ Git installed
&lt;/li&gt;
&lt;li&gt;✅ &lt;a href="https://github.com" rel="noopener noreferrer"&gt;GitHub account&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;✅ Basic knowledge of JavaScript and Node.js&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ Step 1: Create a Simple Node.js App
&lt;/h2&gt;

&lt;p&gt;Open your terminal and run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-app
&lt;span class="nb"&gt;cd &lt;/span&gt;my-app
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a new folder, initializes a Node.js project, and installs Express.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  📝 Step 2: Create index.js
&lt;/h2&gt;

&lt;p&gt;Inside your project folder, create a file called index.js and add the following code:&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 app = express();

app.get('/', (req, res) =&amp;gt; {
  res.send('Hello, Vercel!');
});

app.listen(3000, () =&amp;gt; {
  console.log('Server is running on http://localhost:3000');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sets up a basic Express server that responds with "Hello, Vercel!".&lt;/p&gt;

&lt;h2&gt;
  
  
  🧪 Step 3: Test the App Locally
&lt;/h2&gt;

&lt;p&gt;Run the app locally to make sure everything works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; in your browser — you should see:&lt;/p&gt;

&lt;p&gt;Hello, Vercel!&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Step 4: Prepare for Deployment
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a .gitignore file and ignore node_modules:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo node_modules &amp;gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Initialize a git repository and push it to GitHub:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git
git push -u origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🌐 Step 5: Deploy to Vercel
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://vercel.com" rel="noopener noreferrer"&gt;https://vercel.com&lt;/a&gt; and sign in with your GitHub account.&lt;/li&gt;
&lt;li&gt;Click "New Project".&lt;/li&gt;
&lt;li&gt;Import your repository.&lt;/li&gt;
&lt;li&gt;Leave all settings as default and click "Deploy".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Wait a few moments… and voilà! Your Node.js app is live ✨&lt;/p&gt;

&lt;h2&gt;
  
  
  ✅ Conclusion
&lt;/h2&gt;

&lt;p&gt;You’ve just built and deployed a Node.js app to the web using Express            and Vercel. From here, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build APIs and connect to databases&lt;/li&gt;
&lt;li&gt;Add frontend frameworks like React or Vue&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>deployment</category>
      <category>vercel</category>
    </item>
  </channel>
</rss>
