<?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: Rashedin | FullStack Developer</title>
    <description>The latest articles on DEV Community by Rashedin | FullStack Developer (@dev-rashedin).</description>
    <link>https://dev.to/dev-rashedin</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%2F1284440%2F5e67df64-34da-4f79-bd37-f2a9ffe4e3e6.jpg</url>
      <title>DEV Community: Rashedin | FullStack Developer</title>
      <link>https://dev.to/dev-rashedin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dev-rashedin"/>
    <language>en</language>
    <item>
      <title>How Programming Languages Are Converted into Machine Code</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Wed, 10 Dec 2025 15:09:36 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/how-programming-languages-are-converted-into-machine-code-pil</link>
      <guid>https://dev.to/dev-rashedin/how-programming-languages-are-converted-into-machine-code-pil</guid>
      <description>&lt;p&gt;Programming is pretty much fun! We can do amazing things with programming, such as building a calculator, building a website, or even building an AI Agent (or LLM, you get the idea). But machines don't understand these programming languages directly. They only understand &lt;strong&gt;binary code&lt;/strong&gt; — the 0s and 1s. So each programming language needs to be &lt;strong&gt;compiled or interpreted&lt;/strong&gt; first.&lt;/p&gt;

&lt;p&gt;But there’s more complexity. Not all machines, operating systems, or chips understand the same binary code. That’s why a Windows program cannot run on macOS or Linux. Each platform “speaks” a different machine language.&lt;br&gt;&lt;br&gt;
Let’s break this down in the simplest way possible.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Why Machine Code Is Different on Windows, macOS, and Linux
&lt;/h2&gt;

&lt;p&gt;When you compile a program directly to machine code, the compiler must target:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A specific CPU type&lt;/strong&gt; (Intel, AMD, ARM)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A specific operating system&lt;/strong&gt; (Windows, macOS, Linux)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If either one is different, the binary will not run.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Different CPUs Understand Different Instructions
&lt;/h3&gt;

&lt;p&gt;Every CPU has its own instruction set.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intel/AMD use &lt;strong&gt;x86&lt;/strong&gt; / &lt;strong&gt;x86-64&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Apple M1/M2 use &lt;strong&gt;ARM64&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Many Android devices also use &lt;strong&gt;ARM&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Machine code is literally a list of instructions for the CPU.&lt;br&gt;&lt;br&gt;
So:&lt;/p&gt;

&lt;p&gt;❌ A Windows program compiled for an &lt;strong&gt;Intel x86&lt;/strong&gt; CPU will not run on a Mac with an &lt;strong&gt;ARM&lt;/strong&gt; CPU.&lt;br&gt;&lt;br&gt;
The CPU simply does &lt;em&gt;not understand those instructions&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Different Operating Systems Provide Different System Calls
&lt;/h3&gt;

&lt;p&gt;Even if the CPU is the same (example: Intel), Windows and macOS give programs &lt;strong&gt;different ways to talk to the system&lt;/strong&gt;.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Windows uses APIs like &lt;code&gt;CreateFile()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;macOS/Linux use &lt;code&gt;open()&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;p&gt;❌ Even if the CPU matches, a Windows program won’t run on macOS&lt;br&gt;&lt;br&gt;
because it calls Windows-specific functions that macOS doesn’t have.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Different System Libraries
&lt;/h3&gt;

&lt;p&gt;Windows uses &lt;code&gt;.dll&lt;/code&gt; files.&lt;br&gt;&lt;br&gt;
macOS uses &lt;code&gt;.dylib&lt;/code&gt; files.&lt;br&gt;&lt;br&gt;
Linux uses &lt;code&gt;.so&lt;/code&gt; files.&lt;/p&gt;

&lt;p&gt;Programs depend on these during execution.&lt;/p&gt;

&lt;p&gt;❌ A Windows &lt;code&gt;.exe&lt;/code&gt; cannot find the libraries it needs on macOS.&lt;br&gt;&lt;br&gt;
So it fails.&lt;/p&gt;




&lt;h2&gt;
  
  
  🍎 Easy Analogy: Why It Doesn’t Work
&lt;/h2&gt;

&lt;p&gt;Imagine you write a recipe:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In English
&lt;/li&gt;
&lt;li&gt;Using tools found only in a &lt;strong&gt;Windows kitchen&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now you give it to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Mac chef
&lt;/li&gt;
&lt;li&gt;In a &lt;strong&gt;Mac kitchen&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The chef sees:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Steps written in a different language (CPU instructions mismatch)&lt;/li&gt;
&lt;li&gt;Tools that don’t exist in their kitchen (OS system calls mismatch)&lt;/li&gt;
&lt;li&gt;Ingredients stored differently (system libraries mismatch)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the chef simply cannot follow the recipe.&lt;/p&gt;

&lt;p&gt;That’s why you must compile programs &lt;strong&gt;separately&lt;/strong&gt; for Windows, macOS, and Linux.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Direct Compilation to Machine Code
&lt;/h2&gt;

&lt;p&gt;Some languages compile straight to machine code for a specific CPU and OS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
C, C++, Rust, Go&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flow:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Source Code → Compiler → Machine Code (Windows / macOS / Linux)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Fastest&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Needs a separate binary for each platform&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Bytecode: A Middle Step
&lt;/h2&gt;

&lt;p&gt;Some languages convert your code into &lt;strong&gt;bytecode&lt;/strong&gt;, a portable, OS-independent format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Java, Kotlin, C#, Python&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flow:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Source → Bytecode → Virtual Machine (VM) → Machine Code&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Runs on any OS with a VM&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Slightly slower&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Interpreted + JIT Compilation
&lt;/h2&gt;

&lt;p&gt;Some languages are interpreted but use JIT to speed things up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
JavaScript, Python (PyPy), Ruby&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flow:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Source → Interpreter/JIT → Machine Code&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Transpiled Languages
&lt;/h2&gt;

&lt;p&gt;Some languages convert to another language first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
TypeScript → JavaScript → JIT → Machine Code&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Languages&lt;/th&gt;
&lt;th&gt;How They Run&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Direct Compilation&lt;/td&gt;
&lt;td&gt;C, C++, Rust, Go&lt;/td&gt;
&lt;td&gt;Machine code for a specific CPU + OS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bytecode + VM&lt;/td&gt;
&lt;td&gt;Java, C#, Python&lt;/td&gt;
&lt;td&gt;Bytecode → VM → Machine Code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Interpreted + JIT&lt;/td&gt;
&lt;td&gt;JS, Python, Ruby&lt;/td&gt;
&lt;td&gt;Interpreter/JIT → Machine Code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transpiled&lt;/td&gt;
&lt;td&gt;TypeScript, Elm&lt;/td&gt;
&lt;td&gt;Transpile → JS → JIT → Machine Code&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Key Takeaway:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
We write code in human-friendly languages, but CPUs and operating systems only understand their own binary “dialects.” Compilers, interpreters, VMs, and JIT help translate our code into something the machine can run.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>programming</category>
    </item>
    <item>
      <title>express-error-toolkit — the One NPM Package to Handle All Express Errors</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Tue, 30 Sep 2025 10:01:50 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-32if</link>
      <guid>https://dev.to/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-32if</guid>
      <description>&lt;p&gt;Error handling in Express has always been repetitive:&lt;br&gt;&lt;br&gt;
writing the same &lt;code&gt;notFoundHandler&lt;/code&gt;, &lt;code&gt;globalErrorHandler&lt;/code&gt;, &lt;code&gt;asyncHandler&lt;/code&gt;, and custom error classes across every project.  &lt;/p&gt;

&lt;p&gt;Even with libraries like &lt;code&gt;express-async-errors&lt;/code&gt;, you still end up wiring things manually — and none of them improve the DX in the terminal.  &lt;/p&gt;

&lt;p&gt;That’s why I built — 🔗 &lt;a href="https://www.npmjs.com/package/express-error-toolkit" rel="noopener noreferrer"&gt;express-error-toolkit&lt;/a&gt;  &lt;/p&gt;




&lt;h2&gt;
  
  
  ✨ Core Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;✅ Pre-built middleware: &lt;strong&gt;&lt;code&gt;globalErrorHandler&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;notFoundHandler&lt;/code&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;✅ Type-safe custom error classes (e.g. &lt;strong&gt;&lt;code&gt;NotFoundError&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;BadRequestError&lt;/code&gt;&lt;/strong&gt;)
&lt;/li&gt;
&lt;li&gt;✅ Simple &lt;strong&gt;&lt;code&gt;asyncHandler&lt;/code&gt;&lt;/strong&gt; utility to avoid try-catch blocks
&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;httpError()&lt;/strong&gt; helper for one-liner errors
&lt;/li&gt;
&lt;li&gt;✅ Colorful, readable console logs (no &lt;code&gt;chalk&lt;/code&gt; needed)
&lt;/li&gt;
&lt;li&gt;✅ Works with both CommonJS &amp;amp; ESM
&lt;/li&gt;
&lt;li&gt;✅ Fully configurable (via &lt;code&gt;.env&lt;/code&gt; or code)
&lt;/li&gt;
&lt;li&gt;✅ Built with DX in mind
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;📖 Detailed guide, usage examples &amp;amp; console previews here:&lt;br&gt;&lt;br&gt;
➡️ &lt;a href="https://dev.to/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-869"&gt;Read the full article&lt;/a&gt;  &lt;/p&gt;




&lt;p&gt;If you find it useful, please consider giving it a ⭐ on GitHub 💙&lt;br&gt;&lt;br&gt;
🔗 &lt;a href="https://github.com/dev-rashedin/express-error-toolkit" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>npm</category>
      <category>express</category>
      <category>dx</category>
      <category>errors</category>
    </item>
    <item>
      <title>GPT-5 vs GPT-4: Why Awareness Beats Accuracy</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Tue, 02 Sep 2025 10:51:53 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/gpt-5-vs-gpt-4-why-awareness-beats-accuracy-348m</link>
      <guid>https://dev.to/dev-rashedin/gpt-5-vs-gpt-4-why-awareness-beats-accuracy-348m</guid>
      <description>&lt;p&gt;We’ve all heard the buzz — &lt;em&gt;“GPT-5 is here, and it’s way more powerful.”&lt;/em&gt;&lt;br&gt;&lt;br&gt;
But is that really the case? And more importantly, &lt;strong&gt;what makes it different in practice?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Let’s dive in.  &lt;/p&gt;




&lt;h2&gt;
  
  
  When One Wrong Assumption Breaks Everything
&lt;/h2&gt;

&lt;p&gt;Suppose you’re building a financial projection.&lt;br&gt;&lt;br&gt;
Your inputs are solid, but GPT-4 makes just one wrong assumption in the middle — say it assumes a &lt;strong&gt;15% tax rate instead of 12%&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;Because of that tiny slip:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Profit margin → wrong
&lt;/li&gt;
&lt;li&gt;Cash flow forecast → wrong
&lt;/li&gt;
&lt;li&gt;Final valuation → wrong
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The bigger issue? GPT-4 wouldn’t admit uncertainty. It would confidently declare, &lt;em&gt;“Yes, this is correct,”&lt;/em&gt; even though the foundation was shaky.  &lt;/p&gt;

&lt;p&gt;This is exactly where &lt;strong&gt;GPT-5 changes the game&lt;/strong&gt;.  &lt;/p&gt;




&lt;h2&gt;
  
  
  From Blind Trust → Informed Trust
&lt;/h2&gt;

&lt;p&gt;GPT-5 doesn’t just &lt;em&gt;generate&lt;/em&gt; answers, it &lt;em&gt;audits&lt;/em&gt; them.&lt;br&gt;&lt;br&gt;
It verifies steps, surfaces assumptions, and — when unsure — explicitly flags uncertainty.  &lt;/p&gt;

&lt;p&gt;That means in critical workflows (finance, medicine, law, engineering), you shift from &lt;strong&gt;blind trust&lt;/strong&gt; to &lt;strong&gt;informed trust&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;In practice:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GPT-4 gives you an answer.
&lt;/li&gt;
&lt;li&gt;GPT-5 gives you an answer &lt;strong&gt;plus reasoning, checks, and “confidence markers.”&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This isn’t a small UX improvement — it changes the way you design systems around AI.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Deep Reasoning: From Lottery to Reliability
&lt;/h2&gt;

&lt;p&gt;With GPT-4, deep reasoning felt like rolling dice.&lt;br&gt;&lt;br&gt;
Sometimes you’d get a thoughtful breakdown, other times just a shallow surface-level response.  &lt;/p&gt;

&lt;p&gt;That inconsistency is deadly for:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;System architecture&lt;/strong&gt; (where missing one detail means downtime)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Research&lt;/strong&gt; (where assumptions must be transparent)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legal or compliance writing&lt;/strong&gt; (where precision is non-negotiable)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GPT-5, by contrast, applies something closer to &lt;strong&gt;judgment&lt;/strong&gt;.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Example: Designing a Data Pipeline
&lt;/h2&gt;

&lt;p&gt;Let’s say you ask:&lt;br&gt;&lt;br&gt;
&lt;em&gt;“Design a data pipeline for processing 1M IoT events per second with fault tolerance.”&lt;/em&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GPT-4’s answer&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
A neat diagram — &lt;em&gt;source → processing → storage → dashboard.&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Useful, but shallow.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;GPT-5’s answer&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
It walks through the &lt;em&gt;entire reasoning chain&lt;/em&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where load balancing should happen during ingestion.
&lt;/li&gt;
&lt;li&gt;How to implement backpressure handling.
&lt;/li&gt;
&lt;li&gt;Which nodes replay data during a fault.
&lt;/li&gt;
&lt;li&gt;What thresholds trigger real-time alerts.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Instead of a static diagram, you get a &lt;strong&gt;living blueprint with rationale&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
That’s the difference between a junior engineer sketch and a senior architect review.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Why Awareness &amp;gt; Accuracy
&lt;/h2&gt;

&lt;p&gt;Here’s the key shift:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GPT-4 = Tries to be right.
&lt;/li&gt;
&lt;li&gt;GPT-5 = Tries to be &lt;strong&gt;right *and accountable&lt;/strong&gt;*.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s not that GPT-5 never makes mistakes (it does).&lt;br&gt;&lt;br&gt;
But when it does, you can actually &lt;strong&gt;trace why&lt;/strong&gt; — because it exposes reasoning and assumptions.  &lt;/p&gt;

&lt;p&gt;And in high-stakes work, &lt;em&gt;knowing why&lt;/em&gt; is just as critical as &lt;em&gt;knowing the answer&lt;/em&gt;.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Where This Will Matter Most
&lt;/h2&gt;

&lt;p&gt;Expect GPT-5 to make the biggest impact in domains where &lt;strong&gt;reasoning transparency&lt;/strong&gt; is non-negotiable:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Finance&lt;/strong&gt; → risk modeling, portfolio forecasting.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healthcare&lt;/strong&gt; → diagnostic reasoning, treatment planning.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Engineering&lt;/strong&gt; → system design, performance optimization.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Law &amp;amp; Policy&lt;/strong&gt; → drafting, compliance verification.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In other words: any place where a hidden assumption could cost millions, or even lives.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Closing Thoughts
&lt;/h2&gt;

&lt;p&gt;GPT-4 was a great assistant.&lt;br&gt;&lt;br&gt;
GPT-5 feels more like a &lt;strong&gt;colleague who explains their thinking out loud.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;That shift — from raw output to accountable reasoning — is what makes GPT-5 not just an upgrade, but a &lt;strong&gt;platform shift&lt;/strong&gt; in how we work with AI.  &lt;/p&gt;

&lt;p&gt;If you’ve already experimented with GPT-5, I’d love to hear your stories.&lt;br&gt;&lt;br&gt;
Did it help you catch something GPT-4 would’ve missed? Drop your experiences in the comments below 👇  &lt;/p&gt;

</description>
      <category>gpt5</category>
      <category>chatgpt</category>
      <category>openai</category>
      <category>ai</category>
    </item>
    <item>
      <title>Handle all Express errors effortlessly with a single npm package. Includes built-in globalErrorHandler, notFoundHandler, asyncHandler, custom error classes, and more. The colored console adds a cherry on top, making DX smoother.</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Mon, 01 Sep 2025 11:30:51 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/handle-all-express-errors-effortlessly-with-a-single-npm-package-includes-built-in-h80</link>
      <guid>https://dev.to/dev-rashedin/handle-all-express-errors-effortlessly-with-a-single-npm-package-includes-built-in-h80</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-869" class="crayons-story__hidden-navigation-link"&gt;express-error-toolkit — the One NPM Package to Handle All Express Errors&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="/dev-rashedin" 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%2F1284440%2F5e67df64-34da-4f79-bd37-f2a9ffe4e3e6.jpg" alt="dev-rashedin profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/dev-rashedin" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Rashedin | FullStack Developer
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Rashedin | FullStack Developer
                
              
              &lt;div id="story-author-preview-content-2800681" 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="/dev-rashedin" 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%2F1284440%2F5e67df64-34da-4f79-bd37-f2a9ffe4e3e6.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Rashedin | FullStack Developer&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/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-869" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Aug 28 '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/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-869" id="article-link-2800681"&gt;
          express-error-toolkit — the One NPM Package to Handle All Express Errors
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/npm"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;npm&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/express"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;express&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/dx"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;dx&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/errors"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;errors&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/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-869" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;27&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-869#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              8&lt;span class="hidden s:inline"&gt; comments&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;
            3 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>npm</category>
      <category>express</category>
      <category>dx</category>
      <category>errors</category>
    </item>
    <item>
      <title>express-error-toolkit — the One NPM Package to Handle All Express Errors</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Thu, 28 Aug 2025 10:25:45 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-869</link>
      <guid>https://dev.to/dev-rashedin/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors-869</guid>
      <description>&lt;p&gt;As a full-stack developer, I’ve spent countless hours building robust backend applications with Express.js. While Express is lightweight and unopinionated — exactly what makes it great — error handling has always been repetitive and tedious.&lt;/p&gt;

&lt;p&gt;I was tired of copy-pasting the same boilerplate across projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Writing &lt;strong&gt;&lt;code&gt;notFoundHandler&lt;/code&gt;&lt;/strong&gt; manually&lt;/li&gt;
&lt;li&gt;✅ Writing &lt;strong&gt;&lt;code&gt;globalErrorHandler&lt;/code&gt;&lt;/strong&gt; for every single project&lt;/li&gt;
&lt;li&gt;✅ Wrapping every async function in a try-catch or &lt;strong&gt;&lt;code&gt;asyncHandler&lt;/code&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;✅ Creating &lt;strong&gt;&lt;code&gt;CustomApiError&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;NotFoundError&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;BadrequestError&lt;/code&gt;&lt;/strong&gt; and other custom errors.&lt;/li&gt;
&lt;li&gt;✅ Installing separate libraries like &lt;strong&gt;&lt;code&gt;chalk&lt;/code&gt;&lt;/strong&gt; just to make my logs more readable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even after using popular libraries like &lt;code&gt;express-async-errors&lt;/code&gt; or &lt;code&gt;async-error-handler&lt;/code&gt;, I still had to manually wire up custom errors and error-handling middleware. And none of them improved the developer experience in the terminal.&lt;/p&gt;

&lt;p&gt;So, I built  - 🔗 &lt;a href="https://www.npmjs.com/package/express-error-toolkit" rel="noopener noreferrer"&gt;express-error-toolkit&lt;/a&gt;   — the one package to handle all Express errors.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧰 What's Included?
&lt;/h2&gt;

&lt;p&gt;This package provides everything you need to handle errors in a production-grade Express app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Type-safe custom error classes (&lt;strong&gt;&lt;code&gt;NotFoundError&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;BadRequestError&lt;/code&gt;&lt;/strong&gt;, etc.)&lt;/li&gt;
&lt;li&gt;✅ Drop-in middleware: &lt;strong&gt;&lt;code&gt;globalErrorHandler&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;notFoundHandler&lt;/code&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;✅ A clean &lt;strong&gt;&lt;code&gt;asyncHandler&lt;/code&gt;&lt;/strong&gt; utility&lt;/li&gt;
&lt;li&gt;✅ A &lt;strong&gt;&lt;code&gt;httpError()&lt;/code&gt;&lt;/strong&gt; function for custom one-liners&lt;/li&gt;
&lt;li&gt;✅ Colorful and readable console logs — no need for &lt;strong&gt;&lt;code&gt;chalk&lt;/code&gt;&lt;/strong&gt; or similar&lt;/li&gt;
&lt;li&gt;✅ Flexible &lt;strong&gt;&lt;code&gt;.env&lt;/code&gt;&lt;/strong&gt; or programmatic configuration&lt;/li&gt;
&lt;li&gt;✅ Built-in support for CommonJS and ESM&lt;/li&gt;
&lt;li&gt;✅ Designed with DX in mind&lt;/li&gt;
&lt;/ul&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%2Fjs7lgfffzr9q6kvud1jw.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%2Fjs7lgfffzr9q6kvud1jw.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗 Build Process
&lt;/h2&gt;

&lt;p&gt;The package is written entirely in &lt;strong&gt;TypeScript&lt;/strong&gt; and built with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/egoist/tsup" rel="noopener noreferrer"&gt;tsup&lt;/a&gt; — lightning-fast bundler&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/http-status-toolkit" rel="noopener noreferrer"&gt;http-status-toolkit&lt;/a&gt; — my own utility, to handle http-status-codes in more human readable way&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ANSI escape codes&lt;/strong&gt; — to create colorful terminal output (no dependencies required)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea was to bundle everything in a single utility that you can drop into any Express project, and instantly get a polished, configurable, DX-optimized error system.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ Installation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;express-error-toolkit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;ℹ️ Requires Node.js version &lt;code&gt;&amp;gt;=14&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Make sure you have &lt;strong&gt;&lt;code&gt;express&lt;/code&gt;&lt;/strong&gt; installed in your project.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📦 Usage Examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Wrap async route handlers&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;asyncHandler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/users/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;asyncHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &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="o"&gt;=&amp;gt;&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User not found&lt;/span&gt;&lt;span class="dl"&gt;'&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;h3&gt;
  
  
  2. &lt;strong&gt;Use custom errors&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NotFoundError&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/user/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&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="o"&gt;=&amp;gt;&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NotFoundError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User not found&lt;/span&gt;&lt;span class="dl"&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;h3&gt;
  
  
  3. &lt;strong&gt;Catch unregistered routes&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;notFoundHandler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;notFoundHandler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4. &lt;strong&gt;Global error handler&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;globalErrorHandler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;globalErrorHandler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, it includes stack trace and logs the error, but removes both when &lt;strong&gt;&lt;code&gt;NODE_ENV=production&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 Console Output — Traffic Light Theme
&lt;/h2&gt;

&lt;p&gt;To make debugging more intuitive, &lt;code&gt;express-error-toolkit&lt;/code&gt; uses ANSI escape codes to show:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🔴 &lt;strong&gt;Error Message&lt;/strong&gt; in &lt;strong&gt;bold red&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🟡 &lt;strong&gt;Error Details&lt;/strong&gt; in &lt;strong&gt;bold yellow&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🟢 &lt;strong&gt;Stack Trace&lt;/strong&gt; in &lt;strong&gt;dim green&lt;/strong&gt;, line-by-line&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fmpmwti0bsvdnkilsiy9p.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%2Fmpmwti0bsvdnkilsiy9p.png" alt=" " width="800" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  📸 Console Preview:
&lt;/h3&gt;

&lt;p&gt;Colors are styled without external libraries — just pure ANSI codes&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Optional Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5. &lt;strong&gt;Set Options Globally (Optional)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You can configure the error handling behavior (e.g., hide stack traces, configuring intro line in console, and disable console logging even in development) using either:&lt;/p&gt;

&lt;h4&gt;
  
  
  ✅ Via &amp;amp;&amp;amp; &lt;code&gt;.env&lt;/code&gt;**:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;SHOW_STACK=false LOG_ERROR=false&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  ✅ Or directly in your code:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;setErrorOptions&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
 &lt;span class="nf"&gt;setErrorOptions&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;showStack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;logError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;introLine&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This overrides the default behavior (based on &lt;code&gt;NODE_ENV&lt;/code&gt; or &lt;code&gt;.env&lt;/code&gt; file).&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 Utility Helpers
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;httpError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;StatusCodes&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nf"&gt;httpError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Something broke!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;BAD_REQUEST&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;isCustomAPIError&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;isCustomAPIError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&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;h2&gt;
  
  
  🔥 Why It Improves Developer Experience
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🧼 Cleaner, centralized error handling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;⌛ Saves hours of repetitive setup&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🧠 Human-readable, styled error logs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🚫 No unnecessary dependencies (like &lt;code&gt;chalk&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;⚙️ Easily configurable — no lock-in, no magic&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📁 Output
&lt;/h2&gt;

&lt;p&gt;The build generates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;dist/index.cjs.js&lt;/code&gt; — CommonJS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;dist/index.esm.js&lt;/code&gt; — ESM&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;dist/index.d.ts&lt;/code&gt; — TypeScript types&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💼 Ideal For
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Full-stack teams building REST APIs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Developers who care about clean DX&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Production-ready Express.js apps&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anyone tired of writing error handlers over and over&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧭 Want to Explore?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🔗 &lt;a href="https://www.npmjs.com/package/express-error-toolkit" rel="noopener noreferrer"&gt;View on npm&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;a href="https://github.com/dev-rashedin/express-error-toolkit" rel="noopener noreferrer"&gt;View source on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🌐 &lt;a href="https://www.rashedin.dev" rel="noopener noreferrer"&gt;Visit my portfolio&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📃 License
&lt;/h2&gt;

&lt;p&gt;MIT © &lt;a href="https://www.rashedin.dev" rel="noopener noreferrer"&gt;Rashedin Islam&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🙌 Acknowledgements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.npmjs.com/package/http-status-toolkit" rel="noopener noreferrer"&gt;http-status-toolkit&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ANSI escape codes — for stylish logging without bloat&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Built with ❤️ and TypeScript by &lt;a href="https://www.rashedin.dev" rel="noopener noreferrer"&gt;Rashedin Islam&lt;/a&gt;&lt;br&gt;&lt;br&gt;
If you find it useful, consider giving it a ⭐ on GitHub.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>express</category>
      <category>dx</category>
      <category>errors</category>
    </item>
    <item>
      <title>From ThePracticalDev to DEV: The Story Behind Our Favorite Developer Community</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Thu, 21 Aug 2025 12:06:31 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/from-thepracticaldev-to-dev-the-story-behind-our-favorite-developer-community-cg</link>
      <guid>https://dev.to/dev-rashedin/from-thepracticaldev-to-dev-the-story-behind-our-favorite-developer-community-cg</guid>
      <description>&lt;p&gt;If you’ve been a developer for a while, chances are you’ve read, shared, or even written something on &lt;strong&gt;DEV (dev.to)&lt;/strong&gt;. But do you know how it all started? Let’s take a little trip back in time and see how this amazing community was born, who created it, and why it’s still one of the best places for developers today.&lt;/p&gt;




&lt;h2&gt;
  
  
  👶 The Humble Beginning
&lt;/h2&gt;

&lt;p&gt;It all started in &lt;strong&gt;2014&lt;/strong&gt; with a single Twitter account called &lt;strong&gt;The Practical Dev&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ben Halpern&lt;/strong&gt;, a developer who loved sharing coding tips and memes, created the account. His tweets were short, funny, and relatable for developers. The account quickly grew and became a favorite spot for coding humor and useful programming wisdom.&lt;/p&gt;

&lt;p&gt;But Ben didn’t stop there. He had a bigger dream:&lt;br&gt;&lt;br&gt;
👉 &lt;em&gt;What if there was a place on the internet where developers could share articles, learn from each other, and grow together?&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 The Birth of DEV
&lt;/h2&gt;

&lt;p&gt;In &lt;strong&gt;January 2017&lt;/strong&gt;, that dream came true. Together with &lt;strong&gt;Jess Lee&lt;/strong&gt; and &lt;strong&gt;Peter Frank&lt;/strong&gt;, Ben launched &lt;strong&gt;DEV Community (dev.to)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The idea was simple yet powerful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A blogging platform &lt;strong&gt;for developers, by developers&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;A place where everyone — from beginners to experts — could write, share, and learn without fear of judgment.
&lt;/li&gt;
&lt;li&gt;A community where helpfulness and kindness mattered more than “who’s the smartest.”
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🌟 Major Milestones
&lt;/h2&gt;

&lt;p&gt;Here are some of the big moments in DEV’s journey:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;2017&lt;/strong&gt; → DEV officially launched 🎉
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2018&lt;/strong&gt; → Rapid growth as thousands of developers joined, sharing tutorials, career advice, and personal stories.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2019&lt;/strong&gt; → DEV turned into &lt;strong&gt;Forem&lt;/strong&gt;, an open-source platform. This allowed other communities (not just developers) to build their own “DEV-like” spaces.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2020&lt;/strong&gt; → DEV raised funding to grow even further, while keeping the platform free for users.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Today&lt;/strong&gt; → DEV has millions of members worldwide 🌍. It’s one of the biggest and friendliest developer communities out there.
&lt;/li&gt;
&lt;/ul&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%2F4vmr574gua2tqeql9ay0.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%2F4vmr574gua2tqeql9ay0.png" alt=" " width="800" height="547"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 Why DEV is Special for Developers
&lt;/h2&gt;

&lt;p&gt;There are many blogs and forums out there, but DEV stands out because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Friendly culture&lt;/strong&gt; → The community is welcoming. Even if you’re new to coding, you won’t feel out of place.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open-source spirit&lt;/strong&gt; → DEV itself is built with open-source software (&lt;strong&gt;Forem&lt;/strong&gt;). Developers can contribute to the platform itself!
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Diverse content&lt;/strong&gt; → From JavaScript to Rust, from beginner tips to advanced system design, you’ll find content for every level.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Networking &amp;amp; growth&lt;/strong&gt; → Many developers land jobs, collaborators, or mentors through DEV.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  👩‍💻 The Founders
&lt;/h2&gt;

&lt;p&gt;Let’s not forget the people who made this happen:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ben Halpern&lt;/strong&gt; → The original creator, who started with ThePracticalDev Twitter.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jess Lee&lt;/strong&gt; → Co-founder, helped turn the vision into a real product.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Peter Frank&lt;/strong&gt; → Co-founder, focused on building and scaling the community.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Their shared mission was clear: &lt;strong&gt;make the developer world more welcoming, supportive, and fun.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🎉 The DEV We Know Today
&lt;/h2&gt;

&lt;p&gt;Fast forward to today — DEV is more than a blogging platform. It’s a movement. A place where developers don’t just share code, but also share experiences, failures, lessons, and victories.&lt;/p&gt;

&lt;p&gt;From small side projects to big career moves, DEV has been there for developers at every step.&lt;/p&gt;




&lt;h2&gt;
  
  
  ❤️ Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The journey from &lt;strong&gt;The Practical Dev Twitter account&lt;/strong&gt; to the &lt;strong&gt;DEV Community we know today&lt;/strong&gt; is truly inspiring. It reminds us that with a simple idea, kindness, and a bit of code, you can create something that changes millions of lives.&lt;/p&gt;

&lt;p&gt;So next time you publish an article here, remember — you’re part of a story that started in 2014 with a single tweet. And the best part? &lt;strong&gt;This story is still being written — by us.&lt;/strong&gt; ✨&lt;/p&gt;




&lt;p&gt;👉 &lt;em&gt;What was your first DEV post? Or your favorite memory here? Share it in the comments — let’s celebrate this amazing community together!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>community</category>
      <category>blog</category>
      <category>article</category>
      <category>benhalpern</category>
    </item>
    <item>
      <title>GPT-4 vs GPT-5: From a Developer’s Perspective</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Tue, 19 Aug 2025 10:36:30 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/gpt-4-vs-gpt-5-from-a-developers-perspective-lmd</link>
      <guid>https://dev.to/dev-rashedin/gpt-4-vs-gpt-5-from-a-developers-perspective-lmd</guid>
      <description>&lt;p&gt;GPT-5 is here — and as a developer, you might be wondering: &lt;strong&gt;"What’s really different, and does it matter for my work?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s break it down in plain English.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. A Developer Example
&lt;/h2&gt;

&lt;p&gt;Imagine you ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"Build me an e-commerce site."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;What GPT-4 would do&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It would create a functional site with product listings, a cart, and checkout.&lt;br&gt;&lt;br&gt;
But… it might skip deeper details like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Secure payment integration&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rate limiting for API calls&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to handle heavy traffic during sales&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What GPT-5 does instead&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It goes beyond the basics and starts thinking like a senior engineer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Chooses the right CDN for product images&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adds retry logic if a payment API fails&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Decides between &lt;strong&gt;real-time&lt;/strong&gt; or &lt;strong&gt;batch&lt;/strong&gt; inventory updates&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Plans database indexing for &lt;strong&gt;scaling to millions of users&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; You don’t just get working code — you get a &lt;strong&gt;deploy-ready, well-structured, and edge-case-handled&lt;/strong&gt; codebase.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. A Non-Developer Example
&lt;/h2&gt;

&lt;p&gt;Let’s say you ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"Make me a report."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;GPT-4’s output&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
You’d get a report with data, charts, and summaries — but you might find:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Some data is wrong&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Charts have mismatched scales&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusions lack context&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GPT-5’s output&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It works more carefully:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Verifies&lt;/strong&gt; the data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Detects mismatches in charts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Writes conclusions &lt;strong&gt;with clear context&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If data is uncertain, it warns you:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"I’m not confident about this section — needs verification."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  3. The Reasoning Upgrade
&lt;/h2&gt;

&lt;p&gt;This is where GPT-5 really shines.&lt;br&gt;&lt;br&gt;
With GPT-4, multi-step reasoning could go wrong if one step had an error — leading to &lt;strong&gt;hallucinations&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;GPT-5 changes the process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Works &lt;strong&gt;step-by-step&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross-checks&lt;/strong&gt; its own work&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If unsure, it &lt;strong&gt;tells you&lt;/strong&gt; instead of guessing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fuu03hsfqba8sbd5mzwvv.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%2Fuu03hsfqba8sbd5mzwvv.png" alt=" " width="800" height="449"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;📊 &lt;strong&gt;OpenAI’s data:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hallucinations: &lt;strong&gt;↓ 45%&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Long-context reasoning accuracy: &lt;strong&gt;89%&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Memory Boost
&lt;/h2&gt;

&lt;p&gt;With GPT-4, long chats could lose context — it would “forget” things from earlier in the conversation.&lt;/p&gt;

&lt;p&gt;GPT-5 now supports &lt;strong&gt;256k tokens&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
That means it can remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A &lt;strong&gt;4–5 chapter book&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Weeks&lt;/strong&gt; of chat history&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;strong&gt;large codebase&lt;/strong&gt; — without losing track of variables, dependencies, or previous instructions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5. In Short
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GPT-4&lt;/strong&gt; → An assistant you had to guide constantly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GPT-5&lt;/strong&gt; → A partner that understands the deeper problem, builds solutions accordingly, and adapts — knowing when to go deep and when to keep it short.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;If GPT-4 was like a &lt;strong&gt;junior dev who needed hand-holding&lt;/strong&gt;, GPT-5 feels more like a &lt;strong&gt;tech lead&lt;/strong&gt; — one who thinks about scalability, security, and long-term impact before writing a single line of code.&lt;/p&gt;

&lt;p&gt;For developers, this means less micromanaging, fewer corrections, and more &lt;strong&gt;ready-to-deploy&lt;/strong&gt; results.&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>gptv5</category>
      <category>openai</category>
      <category>ai</category>
    </item>
    <item>
      <title>A lightweight, TypeScript-friendly alternative to http-status-codes with ESM support and localization in 10+ languages. Feedback welcome!</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Tue, 29 Jul 2025 10:26:07 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/a-lightweight-typescript-friendly-alternative-to-http-status-codes-with-esm-support-and-241a</link>
      <guid>https://dev.to/dev-rashedin/a-lightweight-typescript-friendly-alternative-to-http-status-codes-with-esm-support-and-241a</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/dev-rashedin/why-i-built-http-status-toolkit-a-better-alternative-to-http-status-codes-200n" class="crayons-story__hidden-navigation-link"&gt;Why I Built http-status-toolkit — A Better Alternative to http-status-codes&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="/dev-rashedin" 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%2F1284440%2F5e67df64-34da-4f79-bd37-f2a9ffe4e3e6.jpg" alt="dev-rashedin profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/dev-rashedin" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Rashedin | FullStack Developer
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Rashedin | FullStack Developer
                
              
              &lt;div id="story-author-preview-content-2711161" 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="/dev-rashedin" 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%2F1284440%2F5e67df64-34da-4f79-bd37-f2a9ffe4e3e6.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Rashedin | FullStack Developer&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/dev-rashedin/why-i-built-http-status-toolkit-a-better-alternative-to-http-status-codes-200n" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jul 21 '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/dev-rashedin/why-i-built-http-status-toolkit-a-better-alternative-to-http-status-codes-200n" id="article-link-2711161"&gt;
          Why I Built http-status-toolkit — A Better Alternative to http-status-codes
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/npm"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;npm&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/dx"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;dx&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/dev-rashedin/why-i-built-http-status-toolkit-a-better-alternative-to-http-status-codes-200n" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;28&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/dev-rashedin/why-i-built-http-status-toolkit-a-better-alternative-to-http-status-codes-200n#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              10&lt;span class="hidden s:inline"&gt; comments&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>npm</category>
      <category>node</category>
      <category>dx</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why I Built http-status-toolkit — A Better Alternative to http-status-codes</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Mon, 21 Jul 2025 14:40:46 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/why-i-built-http-status-toolkit-a-better-alternative-to-http-status-codes-200n</link>
      <guid>https://dev.to/dev-rashedin/why-i-built-http-status-toolkit-a-better-alternative-to-http-status-codes-200n</guid>
      <description>&lt;p&gt;In my backend projects, I got tired of constantly writing raw status code numbers like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&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;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works — but it's not expressive. And honestly, it makes code harder to read and maintain over time. Like many developers, I wanted something cleaner, more intuitive, and easier to understand at a glance.&lt;/p&gt;

&lt;p&gt;So I looked into existing solutions.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚫 First I Tried &lt;code&gt;http-status-codes&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/http-status-codes" rel="noopener noreferrer"&gt;&lt;code&gt;http-status-codes&lt;/code&gt;&lt;/a&gt; is a well-known package. With it, you can write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;StatusCodes&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http-status-codes&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;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OK&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much better than hardcoded numbers — but it came with a few drawbacks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ No ESM support
&lt;/li&gt;
&lt;li&gt;❌ No localization
&lt;/li&gt;
&lt;li&gt;❌ No detailed reason phrases
&lt;/li&gt;
&lt;li&gt;❌ Separate type definitions (&lt;code&gt;@types/http-status-codes&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;❌ No localization or i18n support &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It didn’t quite solve my problems. So I kept looking.&lt;/p&gt;




&lt;h2&gt;
  
  
  😐 Then I Tried &lt;code&gt;http-status&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/http-status" rel="noopener noreferrer"&gt;&lt;code&gt;http-status&lt;/code&gt;&lt;/a&gt; is another popular choice. It &lt;em&gt;does&lt;/em&gt; support both CommonJS and ESM out of the box — nice. But it still had some limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ No localization or i18n support
&lt;/li&gt;
&lt;li&gt;❌ Only short, generic messages
&lt;/li&gt;
&lt;li&gt;❌ No detailed descriptions for each code
&lt;/li&gt;
&lt;li&gt;❌ Lacks modern TypeScript typings
&lt;/li&gt;
&lt;li&gt;❌ Not tree-shakable
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So again — better than nothing, but not enough.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ So I Built &lt;code&gt;http-status-toolkit&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;I created &lt;a href="https://www.npmjs.com/package/http-status-toolkit" rel="noopener noreferrer"&gt;&lt;code&gt;http-status-toolkit&lt;/code&gt;&lt;/a&gt; to solve all of the above. It’s modern, lightweight, and built for &lt;strong&gt;real-world developer needs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here’s what it offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;TypeScript-first&lt;/strong&gt; with full type safety and autocompletion
&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;ESM and CommonJS support&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Short + detailed&lt;/strong&gt; human-readable messages
&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Localization support&lt;/strong&gt; in 10+ languages
&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Tree-shakable&lt;/strong&gt; and subpath exportable
&lt;/li&gt;
&lt;li&gt;✅ Built with &lt;a href="https://github.com/egoist/tsup" rel="noopener noreferrer"&gt;tsup&lt;/a&gt; for clean, modern builds
&lt;/li&gt;
&lt;li&gt;✅ Extremely lightweight: &lt;strong&gt;~4.1 KB minified / ~2.2 KB gzipped&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Example Usage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getStatusMessage&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http-status-toolkit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OK&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// 200&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getStatusMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NOT_FOUND&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
&lt;span class="c1"&gt;// "Not Found"&lt;/span&gt;

&lt;span class="c1"&gt;// Detailed message&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;DetailedMessages&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http-status-toolkit/messages-detailed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getStatusMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NOT_FOUND&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DetailedMessages&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
&lt;span class="c1"&gt;// "Not Found: The requested resource could not be found but may be available in the future."&lt;/span&gt;

&lt;span class="c1"&gt;// Localized message (Bengali)&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;BengaliMessages&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http-status-toolkit/messages-bn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getStatusMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NOT_FOUND&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BengaliMessages&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: (Not Found message in Bengali)&lt;/span&gt;

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  📊 Feature Comparison
&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%2Fbycrjevfk4j3ndz4v3f9.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%2Fbycrjevfk4j3ndz4v3f9.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📦 &lt;strong&gt;Bundle size is based on &lt;a href="https://bundlephobia.com/" rel="noopener noreferrer"&gt;Bundlephobia&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  💡 Why It Matters
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;http-status-toolkit&lt;/code&gt; improves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Readability&lt;/strong&gt;: No more &lt;code&gt;res.status(403)&lt;/code&gt; — use &lt;code&gt;StatusCodes.FORBIDDEN&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clarity&lt;/strong&gt;: Choose between short, detailed, or localized messages
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Internationalization&lt;/strong&gt;: Easily display meaningful error responses in your users' languages
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developer Experience&lt;/strong&gt;: Clean API, tree-shakable, and TypeScript-native&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧭 Want to Explore?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🔗 &lt;a href="https://www.npmjs.com/package/http-status-toolkit" rel="noopener noreferrer"&gt;View on npm&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;a href="https://github.com/dev-rashedin/http-status-toolkit" rel="noopener noreferrer"&gt;View source on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🌐 &lt;a href="https://www.rashedin.dev" rel="noopener noreferrer"&gt;Visit my portfolio&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Built with ❤️ and TypeScript by &lt;a href="https://www.rashedin.dev" rel="noopener noreferrer"&gt;Rashedin Islam&lt;/a&gt;&lt;br&gt;&lt;br&gt;
If you find it useful, consider giving it a ⭐ on GitHub.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>node</category>
      <category>dx</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Web Dev Origins: The History of npm</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Mon, 14 Jul 2025 11:54:31 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/web-dev-origins-the-history-of-npm-4d2b</link>
      <guid>https://dev.to/dev-rashedin/web-dev-origins-the-history-of-npm-4d2b</guid>
      <description>&lt;p&gt;Whether you're just starting out with JavaScript or leading enterprise-grade frontend architecture, you're almost certainly using npm — the Node Package Manager — every day.&lt;/p&gt;

&lt;p&gt;But do you know why npm was created in the first place?&lt;br&gt;
What problems did it solve?&lt;br&gt;
And why did each major version change the way we code?&lt;/p&gt;

&lt;p&gt;This post is a deep dive into npm’s journey, covering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why it was created&lt;/li&gt;
&lt;li&gt;What developer pain points it solved&lt;/li&gt;
&lt;li&gt;What each major version introduced, and why was npm Created?&lt;/li&gt;
&lt;/ul&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%2F1l5teoqsyaki60qkofsm.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%2F1l5teoqsyaki60qkofsm.png" alt="The History of npm_ Why It Was Created and How It Solved JavaScript’s Biggest Problems " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 2009, Node.js brought JavaScript to the server — a huge step forward. But there was a serious problem:&lt;/p&gt;

&lt;p&gt;❌ There was no reliable way to share and reuse Node.js code across projects.&lt;/p&gt;

&lt;p&gt;Developers were forced to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download ZIP files manually&lt;/li&gt;
&lt;li&gt;Copy-paste utility code across projects&lt;/li&gt;
&lt;li&gt;Clone GitHub repos without versioning control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Isaac Z. Schlueter — a Node.js user himself — found this situation frustrating. So, in early 2010, he created a simple CLI tool to solve it: npm.&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%2F8pzmpwgxvnghtggn9csd.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%2F8pzmpwgxvnghtggn9csd.png" alt="npm_problem_and_solution" width="746" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📈 Major Milestones in npm’s Journey
&lt;/h2&gt;

&lt;p&gt;Let’s walk through npm’s evolution and how each milestone was a direct response to real-world issues.&lt;/p&gt;

&lt;p&gt;🧱&lt;/p&gt;

&lt;h2&gt;
  
  
  2010 — npm CLI Launched
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: Node.js had no default package manager.&lt;/li&gt;
&lt;li&gt;Solution: Isaac Z. Schlueter built npm, introducing:

&lt;ul&gt;
&lt;li&gt;A central registry&lt;/li&gt;
&lt;li&gt;A CLI tool (npm install)&lt;/li&gt;
&lt;li&gt;A metadata file: package.json&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Impact: JavaScript finally had a structured, versioned dependency system.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  🏢 2014 — npm, Inc. Founded
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: npm was growing too fast for one person to manage.&lt;/li&gt;
&lt;li&gt;Solution: Isaac created npm, Inc. to manage the ecosystem, registry, and future development.&lt;/li&gt;
&lt;li&gt;Impact: Provided stability, funding, and a business model (free for public, paid for private).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💥 2016 — The left-pad Incident
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: A tiny package (left-pad) was unpublished and broke thousands of apps.&lt;/li&gt;
&lt;li&gt;Solution: npm changed its policy — popular packages couldn’t be unpublished easily.&lt;/li&gt;
&lt;li&gt;Impact: Forced the ecosystem to consider the importance of dependency stability.&lt;/li&gt;
&lt;/ul&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%2Fszpza8ngfbpbd0dcu1ep.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%2Fszpza8ngfbpbd0dcu1ep.png" alt="left_pad_incident" width="660" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📘 2017 — npm v5: Locking Dependencies with package-lock.json
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: Developers were getting inconsistent installs due to semver ranges in package.json.&lt;/li&gt;
&lt;li&gt;Solution: Introduced package-lock.json:

&lt;ul&gt;
&lt;li&gt;Locks exact versions of every dependency&lt;/li&gt;
&lt;li&gt;Ensures repeatable installs on any machine&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Impact: Faster CI builds, consistent production environments, and easier debugging.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔐 2018 — npm v6: Security Comes First
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: Security vulnerabilities in packages were going undetected.&lt;/li&gt;
&lt;li&gt;Solution: Introduced npm audit, which:

&lt;ul&gt;
&lt;li&gt;Scans installed packages for known issues&lt;/li&gt;
&lt;li&gt;Suggests or applies fixes&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Impact: Security became an essential part of the development process.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  🤝 2020 — GitHub Acquires npm
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: npm’s infrastructure and governance were stretched thin.&lt;/li&gt;
&lt;li&gt;Solution: GitHub (owned by Microsoft) acquired npm, promising to keep it open and free.&lt;/li&gt;
&lt;li&gt;Impact:

&lt;ul&gt;
&lt;li&gt;Stability for the registry&lt;/li&gt;
&lt;li&gt;Deeper CI/CD integrations&lt;/li&gt;
&lt;li&gt;Better security workflows via GitHub Actions&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&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%2Fxvkqynjmxe2wbqfswzm2.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%2Fxvkqynjmxe2wbqfswzm2.png" alt=" " width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🧰 2021 — npm v7: Workspaces and Peer Dependency Fixes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem 1: Managing monorepos was difficult.&lt;/li&gt;
&lt;li&gt;Problem 2: Peer dependency conflicts were common.&lt;/li&gt;
&lt;li&gt;Solution:

&lt;ul&gt;
&lt;li&gt;✅ Workspaces: Native monorepo support&lt;/li&gt;
&lt;li&gt;🔁 Auto-install peer dependencies&lt;/li&gt;
&lt;li&gt;📘 Lockfile v2: Smarter resolution and better VCS diffs&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Impact: npm became more reliable for large-scale projects and package ecosystems.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚡ 2022 — npm v8: Speed &amp;amp; Audit UX
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: The CLI was slower and audit reports were verbose.&lt;/li&gt;
&lt;li&gt;Solution:

&lt;ul&gt;
&lt;li&gt;Enhanced performance and caching&lt;/li&gt;
&lt;li&gt;Improved audit reporting UX&lt;/li&gt;
&lt;li&gt;Fine-grained configuration options&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Impact: Developers got a faster, cleaner, more configurable CLI experience.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔄 2023–2025 — Backend Scaling, CI Integration &amp;amp; Registry Stability
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: The registry needed to scale, CI/CD needed tighter npm integration.&lt;/li&gt;
&lt;li&gt;Solution:

&lt;ul&gt;
&lt;li&gt;Global edge caching for faster package fetches&lt;/li&gt;
&lt;li&gt;Smarter vulnerability resolution in npm audit&lt;/li&gt;
&lt;li&gt;Tighter GitHub Actions integration for npm publish, audit, and scoped packages&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Impact: npm became more stable, CI-friendly, and scalable — without introducing another major CLI version.&lt;/li&gt;

&lt;/ul&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%2Ft3upds2jubocd5ft0kig.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%2Ft3upds2jubocd5ft0kig.png" alt=" " width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 Why This Matters
&lt;/h2&gt;

&lt;p&gt;Every version of npm was created to solve real, developer-facing problems — from code sharing and dependency hell to security and monorepo complexity.&lt;/p&gt;

&lt;p&gt;If you understand why a tool evolved the way it did, you'll not only use it better — you'll build better systems with it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;npm isn’t just a package manager — it’s the backbone of the modern JavaScript ecosystem.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>npm</category>
      <category>node</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Say Goodbye to Try-Catch: Smart Async Error Handling in Express</title>
      <dc:creator>Rashedin | FullStack Developer</dc:creator>
      <pubDate>Tue, 08 Jul 2025 12:11:53 +0000</pubDate>
      <link>https://dev.to/dev-rashedin/say-goodbye-to-try-catch-smart-async-error-handling-in-express-33hi</link>
      <guid>https://dev.to/dev-rashedin/say-goodbye-to-try-catch-smart-async-error-handling-in-express-33hi</guid>
      <description>&lt;p&gt;📌 &lt;strong&gt;This was originally posted on &lt;a href="https://blog.rashedin.dev/smart-async-error-handler-in-express" rel="noopener noreferrer"&gt;blog.rashedin.dev&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When building a backend with Node.js and Express, we're likely using &lt;code&gt;async/await&lt;/code&gt; to handle things like database queries or API calls.&lt;/p&gt;

&lt;p&gt;But there’s a catch — if we don’t handle errors properly, our server can &lt;strong&gt;crash&lt;/strong&gt; or behave &lt;strong&gt;unpredictably&lt;/strong&gt;. 😬&lt;/p&gt;

&lt;p&gt;In this post, you'll learn a &lt;strong&gt;clean, scalable&lt;/strong&gt; way to handle async errors in Express:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why &lt;code&gt;try-catch&lt;/code&gt; in every route is painful
&lt;/li&gt;
&lt;li&gt;How to fix it with a reusable &lt;code&gt;asyncHandler()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;How to simplify this using external libraries
&lt;/li&gt;
&lt;li&gt;How to use my own package: &lt;strong&gt;express-error-toolkit&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;How to define custom error classes
&lt;/li&gt;
&lt;li&gt;And how to set up a global error handler
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚨 The Problem With Try-Catch Everywhere
&lt;/h2&gt;

&lt;p&gt;Here’s how we usually handle errors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/users/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &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="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&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;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&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;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&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;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User not found&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="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&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;p&gt;Repeating this in every route is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Redundant
&lt;/li&gt;
&lt;li&gt;Ugly
&lt;/li&gt;
&lt;li&gt;Easy to forget
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s fix that.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Option 1: Write a Custom &lt;code&gt;asyncHandler&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// utils/asyncHandler.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;asyncHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &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="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;fn&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="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;next&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;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;asyncHandler&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;asyncHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../utils/asyncHandler&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/users/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;asyncHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &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="o"&gt;=&amp;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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&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;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User not found&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="nx"&gt;user&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;p&gt;Clean. Reusable. No &lt;code&gt;try-catch&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  📦 Option 2: Use a Library (Highly Recommended)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔹 express-error-toolkit — &lt;a href="https://www.npmjs.com/package/express-error-toolkit" rel="noopener noreferrer"&gt;View on npm&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;I built this package to make error handling in Express apps much easier. It includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An &lt;code&gt;asyncHandler()&lt;/code&gt; function
&lt;/li&gt;
&lt;li&gt;Predefined error classes (&lt;code&gt;NotFoundError&lt;/code&gt;, &lt;code&gt;BadRequestError&lt;/code&gt;, etc.)
&lt;/li&gt;
&lt;li&gt;A global error-handling middleware
&lt;/li&gt;
&lt;li&gt;Clean stack traces in development&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Install
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;express-error-toolkit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Use
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;asyncHandler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/users/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;asyncHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &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="o"&gt;=&amp;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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&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;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User not found&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="nx"&gt;user&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;h2&gt;
  
  
  🧱 Define Custom Error Classes
&lt;/h2&gt;

&lt;p&gt;If you don’t use a package, you can define your own:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// utils/ApiError.js&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApiError&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;captureStackTrace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;constructor&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;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ApiError&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ApiError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../utils/ApiError&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApiError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User not found&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Or use express-error-toolkit’s built-in errors
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NotFoundError&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NotFoundError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User not found&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🌍 Global Error-Handling Middleware
&lt;/h2&gt;

&lt;p&gt;Add this at the &lt;strong&gt;end&lt;/strong&gt; of your middleware chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&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="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;500&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;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Internal Server Error&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;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;status&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;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODE_ENV&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;production&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stack&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;h3&gt;
  
  
  Or use express-error-toolkit’s built-in handler:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;globalErrorHandler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;globalErrorHandler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧪 Full Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&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;mongoose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongoose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;NotFoundError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;asyncHandler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;globalErrorHandler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-error-toolkit&lt;/span&gt;&lt;span class="dl"&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/users/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;asyncHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &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="o"&gt;=&amp;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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findById&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;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NotFoundError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User not found&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="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}));&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;globalErrorHandler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server running on port 3000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧠 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;✅ Avoid &lt;code&gt;try-catch&lt;/code&gt; in every route using &lt;code&gt;asyncHandler&lt;/code&gt;&lt;br&gt;&lt;br&gt;
📦 Use &lt;strong&gt;express-error-toolkit&lt;/strong&gt; for a full-featured, clean setup&lt;br&gt;&lt;br&gt;
🧱 Throw meaningful errors with custom classes&lt;br&gt;&lt;br&gt;
🌍 Catch and format all errors in one global middleware&lt;/p&gt;

&lt;p&gt;Follow this approach and your Express backend will be clean, scalable, and production-ready.&lt;/p&gt;

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