<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Rashedin’s Dev Diary]]></title><description><![CDATA[A personal space where code meets creativity—sharing my journey, insights, and reflections on programming to inspire fellow developers and curious minds alike.]]></description><link>https://blog.rashedin.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1756820225083/ad32ebd4-744a-45a1-bcb2-955171e247da.png</url><title>Rashedin’s Dev Diary</title><link>https://blog.rashedin.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 09:08:14 GMT</lastBuildDate><atom:link href="https://blog.rashedin.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How Programming Languages Are Converted into Machine Code]]></title><description><![CDATA[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....]]></description><link>https://blog.rashedin.dev/how-programming-languages-are-converted-into-machine-code</link><guid isPermaLink="true">https://blog.rashedin.dev/how-programming-languages-are-converted-into-machine-code</guid><category><![CDATA[programming languages]]></category><category><![CDATA[machine coding]]></category><category><![CDATA[binary]]></category><category><![CDATA[operating system]]></category><category><![CDATA[compilers]]></category><dc:creator><![CDATA[Rashedin Islam]]></dc:creator><pubDate>Thu, 11 Dec 2025 10:20:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1765367713927/962bc87b-0999-4b89-bdbe-e1e62c9350e0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>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 <strong>binary code</strong> — the 0s and 1s. So each programming language needs to be <strong>compiled or interpreted</strong> first.</p>
<p>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.<br />Let’s break this down in the simplest way possible.</p>
<hr />
<h2 id="heading-why-machine-code-is-different-on-windows-macos-and-linux">🧠 Why Machine Code Is Different on Windows, macOS, and Linux</h2>
<p>When you compile a program directly to machine code, the compiler must target:</p>
<ol>
<li><strong>A specific CPU type</strong> (Intel, AMD, ARM)</li>
<li><strong>A specific operating system</strong> (Windows, macOS, Linux)</li>
</ol>
<p>If either one is different, the binary will not run.</p>
<h3 id="heading-1-different-cpus-understand-different-instructions">1. Different CPUs Understand Different Instructions</h3>
<p>Every CPU has its own instruction set.  </p>
<ul>
<li>Intel/AMD use <strong>x86</strong> / <strong>x86-64</strong>  </li>
<li>Apple M1/M2 use <strong>ARM64</strong>  </li>
<li>Many Android devices also use <strong>ARM</strong></li>
</ul>
<p>Machine code is literally a list of instructions for the CPU.<br />So:</p>
<p>❌ A Windows program compiled for an <strong>Intel x86</strong> CPU will not run on a Mac with an <strong>ARM</strong> CPU.<br />The CPU simply does <em>not understand those instructions</em>.</p>
<h3 id="heading-2-different-operating-systems-provide-different-system-calls">2. Different Operating Systems Provide Different System Calls</h3>
<p>Even if the CPU is the same (example: Intel), Windows and macOS give programs <strong>different ways to talk to the system</strong>.</p>
<p>For example:</p>
<ul>
<li>Windows uses APIs like <code>CreateFile()</code></li>
<li>macOS/Linux use <code>open()</code></li>
</ul>
<p>So:</p>
<p>❌ Even if the CPU matches, a Windows program won’t run on macOS<br />because it calls Windows-specific functions that macOS doesn’t have.</p>
<h3 id="heading-3-different-system-libraries">3. Different System Libraries</h3>
<p>Windows uses <code>.dll</code> files.<br />macOS uses <code>.dylib</code> files.<br />Linux uses <code>.so</code> files.</p>
<p>Programs depend on these during execution.</p>
<p>❌ A Windows <code>.exe</code> cannot find the libraries it needs on macOS.<br />So it fails.</p>
<hr />
<h2 id="heading-easy-analogy-why-it-doesnt-work">🍎 Easy Analogy: Why It Doesn’t Work</h2>
<p>Imagine you write a recipe:</p>
<ul>
<li>In English  </li>
<li>Using tools found only in a <strong>Windows kitchen</strong></li>
</ul>
<p>Now you give it to:</p>
<ul>
<li>A Mac chef  </li>
<li>In a <strong>Mac kitchen</strong></li>
</ul>
<p>The chef sees:</p>
<ul>
<li>Steps written in a different language (CPU instructions mismatch)</li>
<li>Tools that don’t exist in their kitchen (OS system calls mismatch)</li>
<li>Ingredients stored differently (system libraries mismatch)</li>
</ul>
<p>So the chef simply cannot follow the recipe.</p>
<p>That’s why you must compile programs <strong>separately</strong> for Windows, macOS, and Linux.</p>
<hr />
<h2 id="heading-1-direct-compilation-to-machine-code">1. Direct Compilation to Machine Code</h2>
<p>Some languages compile straight to machine code for a specific CPU and OS.</p>
<p><strong>Examples:</strong><br />C, C++, Rust, Go</p>
<p><strong>Flow:</strong><br />Source Code → Compiler → Machine Code (Windows / macOS / Linux)</p>
<p><strong>Pros:</strong> Fastest<br /><strong>Cons:</strong> Needs a separate binary for each platform</p>
<hr />
<h2 id="heading-2-bytecode-a-middle-step">2. Bytecode: A Middle Step</h2>
<p>Some languages convert your code into <strong>bytecode</strong>, a portable, OS-independent format.</p>
<p><strong>Examples:</strong><br />Java, Kotlin, C#, Python</p>
<p><strong>Flow:</strong><br />Source → Bytecode → Virtual Machine (VM) → Machine Code</p>
<p><strong>Pros:</strong> Runs on any OS with a VM<br /><strong>Cons:</strong> Slightly slower</p>
<hr />
<h2 id="heading-3-interpreted-jit-compilation">3. Interpreted + JIT Compilation</h2>
<p>Some languages are interpreted but use JIT to speed things up.</p>
<p><strong>Examples:</strong><br />JavaScript, Python (PyPy), Ruby</p>
<p><strong>Flow:</strong><br />Source → Interpreter/JIT → Machine Code</p>
<hr />
<h2 id="heading-4-transpiled-languages">4. Transpiled Languages</h2>
<p>Some languages convert to another language first.</p>
<p><strong>Examples:</strong><br />TypeScript → JavaScript → JIT → Machine Code</p>
<hr />
<h2 id="heading-summary-table">Summary Table</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Approach</td><td>Languages</td><td>How They Run</td></tr>
</thead>
<tbody>
<tr>
<td>Direct Compilation</td><td>C, C++, Rust, Go</td><td>Machine code for a specific CPU + OS</td></tr>
<tr>
<td>Bytecode + VM</td><td>Java, C#, Python</td><td>Bytecode → VM → Machine Code</td></tr>
<tr>
<td>Interpreted + JIT</td><td>JS, Python, Ruby</td><td>Interpreter/JIT → Machine Code</td></tr>
<tr>
<td>Transpiled</td><td>TypeScript, Elm</td><td>Transpile → JS → JIT → Machine Code</td></tr>
</tbody>
</table>
</div><hr />
<p><strong>Key Takeaway:</strong><br />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.</p>
]]></content:encoded></item><item><title><![CDATA[GPT-5 vs GPT-4: A Deep Dive Into Reasoning, Awareness, and Reliability]]></title><description><![CDATA[We’ve all heard the buzz — “GPT-5 is here, and it’s way more powerful.”But is that really the case? And more importantly, what makes it different in practice?Let’s dive in.  

When One Wrong Assumption Breaks Everything
Suppose you’re building a fina...]]></description><link>https://blog.rashedin.dev/gpt-5-vs-gpt-4-a-deep-dive-into-reasoning-awareness-and-reliability</link><guid isPermaLink="true">https://blog.rashedin.dev/gpt-5-vs-gpt-4-a-deep-dive-into-reasoning-awareness-and-reliability</guid><category><![CDATA[gpt5]]></category><category><![CDATA[chatgpt]]></category><category><![CDATA[openai]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[Rashedin Islam]]></dc:creator><pubDate>Mon, 08 Sep 2025 10:20:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1756809955997/869fa5d9-20eb-4c6a-9e20-e5194ba817c4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We’ve all heard the buzz — <em>“GPT-5 is here, and it’s way more powerful.”</em><br />But is that really the case? And more importantly, <strong>what makes it different in practice?</strong><br />Let’s dive in.  </p>
<hr />
<h2 id="heading-when-one-wrong-assumption-breaks-everything">When One Wrong Assumption Breaks Everything</h2>
<p>Suppose you’re building a financial projection.<br />Your inputs are solid, but GPT-4 makes just one wrong assumption in the middle — say it assumes a <strong>15% tax rate instead of 12%</strong>.  </p>
<p>Because of that tiny slip:  </p>
<ul>
<li>Profit margin → wrong  </li>
<li>Cash flow forecast → wrong  </li>
<li>Final valuation → wrong  </li>
</ul>
<p>The bigger issue? GPT-4 wouldn’t admit uncertainty. It would confidently declare, <em>“Yes, this is correct,”</em> even though the foundation was shaky.  </p>
<p>This is exactly where <strong>GPT-5 changes the game</strong>.  </p>
<hr />
<h2 id="heading-from-blind-trust-informed-trust">From Blind Trust → Informed Trust</h2>
<p>GPT-5 doesn’t just <em>generate</em> answers, it <em>audits</em> them.<br />It verifies steps, surfaces assumptions, and — when unsure — explicitly flags uncertainty.  </p>
<p>That means in critical workflows (finance, medicine, law, engineering), you shift from <strong>blind trust</strong> to <strong>informed trust</strong>.  </p>
<p>In practice:  </p>
<ul>
<li>GPT-4 gives you an answer.  </li>
<li>GPT-5 gives you an answer <strong>plus reasoning, checks, and “confidence markers.”</strong>  </li>
</ul>
<p>This isn’t a small UX improvement — it changes the way you design systems around AI.  </p>
<hr />
<h2 id="heading-deep-reasoning-from-lottery-to-reliability">Deep Reasoning: From Lottery to Reliability</h2>
<p>With GPT-4, deep reasoning felt like rolling dice.<br />Sometimes you’d get a thoughtful breakdown, other times just a shallow surface-level response.  </p>
<p>That inconsistency is deadly for:  </p>
<ul>
<li><strong>System architecture</strong> (where missing one detail means downtime)  </li>
<li><strong>Research</strong> (where assumptions must be transparent)  </li>
<li><strong>Legal or compliance writing</strong> (where precision is non-negotiable)  </li>
</ul>
<p>GPT-5, by contrast, applies something closer to <strong>judgment</strong>.  </p>
<hr />
<h2 id="heading-example-designing-a-data-pipeline">Example: Designing a Data Pipeline</h2>
<p>Let’s say you ask:<br /><em>“Design a data pipeline for processing 1M IoT events per second with fault tolerance.”</em>  </p>
<ul>
<li><p><strong>GPT-4’s answer</strong>:<br />A neat diagram — <em>source → processing → storage → dashboard.</em><br />Useful, but shallow.  </p>
</li>
<li><p><strong>GPT-5’s answer</strong>:<br />It walks through the <em>entire reasoning chain</em>:  </p>
<ul>
<li>Where load balancing should happen during ingestion.  </li>
<li>How to implement backpressure handling.  </li>
<li>Which nodes replay data during a fault.  </li>
<li>What thresholds trigger real-time alerts.  </li>
</ul>
</li>
</ul>
<p>Instead of a static diagram, you get a <strong>living blueprint with rationale</strong>.<br />That’s the difference between a junior engineer sketch and a senior architect review.  </p>
<hr />
<h2 id="heading-why-awareness-gt-accuracy">Why Awareness &gt; Accuracy</h2>
<p>Here’s the key shift:  </p>
<ul>
<li>GPT-4 = Tries to be right.  </li>
<li>GPT-5 = Tries to be <strong>right <em>and accountable</em></strong>.  </li>
</ul>
<p>It’s not that GPT-5 never makes mistakes (it does).<br />But when it does, you can actually <strong>trace why</strong> — because it exposes reasoning and assumptions.  </p>
<p>And in high-stakes work, <em>knowing why</em> is just as critical as <em>knowing the answer</em>.  </p>
<hr />
<h2 id="heading-where-this-will-matter-most">Where This Will Matter Most</h2>
<p>Expect GPT-5 to make the biggest impact in domains where <strong>reasoning transparency</strong> is non-negotiable:  </p>
<ul>
<li><strong>Finance</strong> → risk modeling, portfolio forecasting.  </li>
<li><strong>Healthcare</strong> → diagnostic reasoning, treatment planning.  </li>
<li><strong>Engineering</strong> → system design, performance optimization.  </li>
<li><strong>Law &amp; Policy</strong> → drafting, compliance verification.  </li>
</ul>
<p>In other words: any place where a hidden assumption could cost millions, or even lives.  </p>
<hr />
<h2 id="heading-closing-thoughts">Closing Thoughts</h2>
<p>GPT-4 was a great assistant.<br />GPT-5 feels more like a <strong>colleague who explains their thinking out loud.</strong>  </p>
<p>That shift — from raw output to accountable reasoning — is what makes GPT-5 not just an upgrade, but a <strong>platform shift</strong> in how we work with AI.  </p>
<p>If you’ve already experimented with GPT-5, I’d love to hear your stories.<br />Did it help you catch something GPT-4 would’ve missed? Drop your experiences in the comments below 👇  </p>
]]></content:encoded></item><item><title><![CDATA[express-error-toolkit — the One NPM Package to Handle All Express Errors]]></title><description><![CDATA[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.
I was ti...]]></description><link>https://blog.rashedin.dev/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors</link><guid isPermaLink="true">https://blog.rashedin.dev/express-error-toolkit-the-one-npm-package-to-handle-all-express-errors</guid><category><![CDATA[DX]]></category><category><![CDATA[Express]]></category><category><![CDATA[error handling]]></category><category><![CDATA[npm]]></category><dc:creator><![CDATA[Rashedin Islam]]></dc:creator><pubDate>Mon, 01 Sep 2025 11:42:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1756726495693/274eb29c-7390-4879-ab4a-babf477754b1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>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.</p>
<p>I was tired of copy-pasting the same boilerplate across projects:</p>
<ul>
<li>✅ Writing <strong><code>notFoundHandler</code></strong> manually</li>
<li>✅ Writing <strong><code>globalErrorHandler</code></strong> for every single project</li>
<li>✅ Wrapping every async function in a try-catch or <strong><code>asyncHandler</code></strong></li>
<li>✅ Creating <strong><code>CustomApiError</code></strong>, <strong><code>NotFoundError</code></strong>, <strong><code>BadrequestError</code></strong> and other custom errors.</li>
<li>✅ Installing separate libraries like <strong><code>chalk</code></strong> just to make my logs more readable</li>
</ul>
<p>Even after using popular libraries like <code>express-async-errors</code> or <code>async-error-handler</code>, I still had to manually wire up custom errors and error-handling middleware. And none of them improved the developer experience in the terminal.</p>
<p>So, I built  - 🔗 <a target="_blank" href="https://www.npmjs.com/package/express-error-toolkit">express-error-toolkit</a>   — the one package to handle all Express errors.</p>
<hr />
<h2 id="heading-whats-included">🧰 What's Included?</h2>
<p>This package provides everything you need to handle errors in a production-grade Express app:</p>
<ul>
<li>✅ Type-safe custom error classes (<strong><code>NotFoundError</code></strong>, <strong><code>BadRequestError</code></strong>, etc.)</li>
<li>✅ Drop-in middleware: <strong><code>globalErrorHandler</code></strong>, <strong><code>notFoundHandler</code></strong></li>
<li>✅ A clean <strong><code>asyncHandler</code></strong> utility</li>
<li>✅ A <strong><code>httpError()</code></strong> function for custom one-liners</li>
<li>✅ Colorful and readable console logs — no need for <strong><code>chalk</code></strong> or similar</li>
<li>✅ Flexible <strong><code>.env</code></strong> or programmatic configuration</li>
<li>✅ Built-in support for CommonJS and ESM</li>
<li>✅ Designed with DX in mind</li>
</ul>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/js7lgfffzr9q6kvud1jw.png" alt="Image description" /></p>
<hr />
<h2 id="heading-build-process">🏗 Build Process</h2>
<p>The package is written entirely in <strong>TypeScript</strong> and built with:</p>
<ul>
<li><a target="_blank" href="https://github.com/egoist/tsup">tsup</a> — lightning-fast bundler</li>
<li><a target="_blank" href="https://www.npmjs.com/package/http-status-toolkit">http-status-toolkit</a> — my own utility, to handle http-status-codes in more human readable way</li>
<li><strong>ANSI escape codes</strong> — to create colorful terminal output (no dependencies required)</li>
</ul>
<p>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.</p>
<hr />
<h2 id="heading-installation">⚡ Installation</h2>
<pre><code class="lang-bash">npm install express-error-toolkit
</code></pre>
<blockquote>
<p>ℹ️ Requires Node.js version <code>&gt;=14</code></p>
<p>Make sure you have <strong><code>express</code></strong> installed in your project.</p>
</blockquote>
<hr />
<h2 id="heading-usage-examples">📦 Usage Examples</h2>
<h3 id="heading-1-wrap-async-route-handlers">1. <strong>Wrap async route handlers</strong></h3>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { asyncHandler } <span class="hljs-keyword">from</span> <span class="hljs-string">'express-error-toolkit'</span>;

app.get(<span class="hljs-string">'/users/:id'</span>, asyncHandler(<span class="hljs-keyword">async</span> (req, res) =&gt; 
{<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'User not found'</span>);   }) );
</code></pre>
<hr />
<h3 id="heading-2-use-custom-errors">2. <strong>Use custom errors</strong></h3>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { NotFoundError } <span class="hljs-keyword">from</span> <span class="hljs-string">'express-error-toolkit'</span>;  

app.get(<span class="hljs-string">'/user/:id'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> 
{<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> NotFoundError(<span class="hljs-string">'User not found'</span>); });
</code></pre>
<hr />
<h3 id="heading-3-catch-unregistered-routes">3. <strong>Catch unregistered routes</strong></h3>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { notFoundHandler } <span class="hljs-keyword">from</span> <span class="hljs-string">'express-error-toolkit'</span>;

app.use(notFoundHandler);
</code></pre>
<hr />
<h3 id="heading-4-global-error-handler">4. <strong>Global error handler</strong></h3>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { globalErrorHandler } <span class="hljs-keyword">from</span> <span class="hljs-string">'express-error-toolkit'</span>;  

app.use(globalErrorHandler);
</code></pre>
<p>By default, it includes stack trace and logs the error, but removes both when <strong><code>NODE_ENV=production</code></strong>.</p>
<hr />
<h2 id="heading-console-output-traffic-light-theme">🧪 Console Output — Traffic Light Theme</h2>
<p>To make debugging more intuitive, <code>express-error-toolkit</code> uses ANSI escape codes to show:</p>
<ul>
<li><p>🔴 <strong>Error Message</strong> in <strong>bold red</strong></p>
</li>
<li><p>🟡 <strong>Error Details</strong> in <strong>bold yellow</strong></p>
</li>
<li><p>🟢 <strong>Stack Trace</strong> in <strong>dim green</strong>, line-by-line</p>
</li>
</ul>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpmwti0bsvdnkilsiy9p.png" alt="Image description" /></p>
<h3 id="heading-console-preview">📸 Console Preview:</h3>
<p><sub>Colors are styled without external libraries — just pure ANSI codes</sub></p>
<hr />
<h2 id="heading-optional-configuration">🛠️ Optional Configuration</h2>
<h3 id="heading-5-set-options-globally-optional">5. <strong>Set Options Globally (Optional)</strong></h3>
<p>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:</p>
<h4 id="heading-via-ampamp-env">✅ Via &amp;&amp; <code>.env</code>**:</h4>
<p><strong><code>SHOW_STACK=false LOG_ERROR=false</code></strong></p>
<h4 id="heading-or-directly-in-your-code">✅ Or directly in your code:</h4>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { setErrorOptions } <span class="hljs-keyword">from</span> <span class="hljs-string">'express-error-toolkit'</span>; 
 setErrorOptions({showStack: <span class="hljs-literal">false</span>, logError: <span class="hljs-literal">false</span>, introLine: <span class="hljs-literal">false</span> });
</code></pre>
<p>This overrides the default behavior (based on <code>NODE_ENV</code> or <code>.env</code> file).</p>
<hr />
<h2 id="heading-utility-helpers">📚 Utility Helpers</h2>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { httpError, StatusCodes } <span class="hljs-keyword">from</span> <span class="hljs-string">'express-error-toolkit'</span>;

<span class="hljs-keyword">throw</span> httpError(<span class="hljs-string">'Something broke!'</span>, StatusCodes.BAD_REQUEST);
</code></pre>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { isCustomAPIError } <span class="hljs-keyword">from</span> <span class="hljs-string">'express-error-toolkit'</span>;  

<span class="hljs-keyword">if</span> (isCustomAPIError(err)) {   <span class="hljs-built_in">console</span>.log(err.statusCode, err.message); }
</code></pre>
<hr />
<h2 id="heading-why-it-improves-developer-experience">🔥 Why It Improves Developer Experience</h2>
<ul>
<li><p>🧼 Cleaner, centralized error handling</p>
</li>
<li><p>⌛ Saves hours of repetitive setup</p>
</li>
<li><p>🧠 Human-readable, styled error logs</p>
</li>
<li><p>🚫 No unnecessary dependencies (like <code>chalk</code>)</p>
</li>
<li><p>⚙️ Easily configurable — no lock-in, no magic</p>
</li>
</ul>
<hr />
<h2 id="heading-output">📁 Output</h2>
<p>The build generates:</p>
<ul>
<li><p><code>dist/index.cjs.js</code> — CommonJS</p>
</li>
<li><p><code>dist/index.esm.js</code> — ESM</p>
</li>
<li><p><code>dist/index.d.ts</code> — TypeScript types</p>
</li>
</ul>
<hr />
<h2 id="heading-ideal-for">💼 Ideal For</h2>
<ul>
<li><p>Full-stack teams building REST APIs</p>
</li>
<li><p>Developers who care about clean DX</p>
</li>
<li><p>Production-ready Express.js apps</p>
</li>
<li><p>Anyone tired of writing error handlers over and over</p>
</li>
</ul>
<hr />
<h2 id="heading-want-to-explore">🧭 Want to Explore?</h2>
<ul>
<li>🔗 <a target="_blank" href="https://www.npmjs.com/package/express-error-toolkit">View on npm</a>  </li>
<li>💻 <a target="_blank" href="https://github.com/dev-rashedin/express-error-toolkit">View source on GitHub</a>  </li>
<li>🌐 <a target="_blank" href="https://www.rashedin.dev">Visit my portfolio</a></li>
</ul>
<hr />
<h2 id="heading-license">📃 License</h2>
<p>MIT © <a target="_blank" href="https://www.rashedin.dev">Rashedin Islam</a></p>
<hr />
<h2 id="heading-acknowledgements">🙌 Acknowledgements</h2>
<ul>
<li><p><a target="_blank" href="https://www.npmjs.com/package/http-status-toolkit">http-status-toolkit</a> </p>
</li>
<li><p>ANSI escape codes — for stylish logging without bloat</p>
</li>
</ul>
<hr />
<p>Built with ❤️ and TypeScript by <a target="_blank" href="https://www.rashedin.dev">Rashedin Islam</a><br />If you find it useful, consider giving it a ⭐ on GitHub.</p>
]]></content:encoded></item><item><title><![CDATA[GPT-4 vs GPT-5: From a Developer’s Perspective]]></title><description><![CDATA[GPT-5 is here — and as a developer, you might be wondering: "What’s really different, and does it matter for my work?"
Let’s break it down in plain English.

1. A Developer Example
Imagine you ask:

"Build me an e-commerce site."

What GPT-4 would do...]]></description><link>https://blog.rashedin.dev/gpt-4-vs-gpt-5-from-a-developers-perspective</link><guid isPermaLink="true">https://blog.rashedin.dev/gpt-4-vs-gpt-5-from-a-developers-perspective</guid><category><![CDATA[GPT 4]]></category><category><![CDATA[gpt5]]></category><category><![CDATA[AI]]></category><category><![CDATA[openai]]></category><dc:creator><![CDATA[Rashedin Islam]]></dc:creator><pubDate>Mon, 25 Aug 2025 11:09:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1756119936282/2d37eefe-9298-47c1-9abc-c66981e53291.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>GPT-5 is here — and as a developer, you might be wondering: <strong>"What’s really different, and does it matter for my work?"</strong></p>
<p>Let’s break it down in plain English.</p>
<hr />
<h2 id="heading-1-a-developer-example">1. A Developer Example</h2>
<p>Imagine you ask:</p>
<blockquote>
<p><strong>"Build me an e-commerce site."</strong></p>
</blockquote>
<p><strong>What GPT-4 would do</strong><br />It would create a functional site with product listings, a cart, and checkout.<br />But… it might skip deeper details like:</p>
<ul>
<li><p>Secure payment integration</p>
</li>
<li><p>Rate limiting for API calls</p>
</li>
<li><p>How to handle heavy traffic during sales</p>
</li>
</ul>
<p><strong>What GPT-5 does instead</strong><br />It goes beyond the basics and starts thinking like a senior engineer:</p>
<ul>
<li><p>Chooses the right CDN for product images</p>
</li>
<li><p>Adds retry logic if a payment API fails</p>
</li>
<li><p>Decides between <strong>real-time</strong> or <strong>batch</strong> inventory updates</p>
</li>
<li><p>Plans database indexing for <strong>scaling to millions of users</strong></p>
</li>
</ul>
<p><strong>Result:</strong> You don’t just get working code — you get a <strong>deploy-ready, well-structured, and edge-case-handled</strong> codebase.</p>
<hr />
<h2 id="heading-2-a-non-developer-example">2. A Non-Developer Example</h2>
<p>Let’s say you ask:</p>
<blockquote>
<p><strong>"Make me a report."</strong></p>
</blockquote>
<p><strong>GPT-4’s output</strong><br />You’d get a report with data, charts, and summaries — but you might find:</p>
<ul>
<li><p>Some data is wrong</p>
</li>
<li><p>Charts have mismatched scales</p>
</li>
<li><p>Conclusions lack context</p>
</li>
</ul>
<p><strong>GPT-5’s output</strong><br />It works more carefully:</p>
<ol>
<li><p><strong>Verifies</strong> the data</p>
</li>
<li><p>Detects mismatches in charts</p>
</li>
<li><p>Writes conclusions <strong>with clear context</strong></p>
</li>
<li><p>If data is uncertain, it warns you:</p>
<blockquote>
<p><em>"I’m not confident about this section — needs verification."</em></p>
</blockquote>
</li>
</ol>
<hr />
<h2 id="heading-3-the-reasoning-upgrade">3. The Reasoning Upgrade</h2>
<p>This is where GPT-5 really shines.<br />With GPT-4, multi-step reasoning could go wrong if one step had an error — leading to <strong>hallucinations</strong>.</p>
<p>GPT-5 changes the process:</p>
<ul>
<li><p>Works <strong>step-by-step</strong></p>
</li>
<li><p><strong>Cross-checks</strong> its own work</p>
</li>
<li><p>If unsure, it <strong>tells you</strong> instead of guessing</p>
</li>
</ul>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu03hsfqba8sbd5mzwvv.png" alt="Image description" /> </p>
<p>📊 <strong>OpenAI’s data:</strong></p>
<ul>
<li><p>Hallucinations: <strong>↓ 45%</strong></p>
</li>
<li><p>Long-context reasoning accuracy: <strong>89%</strong></p>
</li>
</ul>
<hr />
<h2 id="heading-4-memory-boost">4. Memory Boost</h2>
<p>With GPT-4, long chats could lose context — it would “forget” things from earlier in the conversation.</p>
<p>GPT-5 now supports <strong>256k tokens</strong>.<br />That means it can remember:</p>
<ul>
<li><p>A <strong>4–5 chapter book</strong></p>
</li>
<li><p><strong>Weeks</strong> of chat history</p>
</li>
<li><p>A <strong>large codebase</strong> — without losing track of variables, dependencies, or previous instructions</p>
</li>
</ul>
<hr />
<h2 id="heading-5-in-short">5. In Short</h2>
<ul>
<li><p><strong>GPT-4</strong> → An assistant you had to guide constantly.</p>
</li>
<li><p><strong>GPT-5</strong> → A partner that understands the deeper problem, builds solutions accordingly, and adapts — knowing when to go deep and when to keep it short.</p>
</li>
</ul>
<hr />
<h3 id="heading-final-thoughts">Final Thoughts</h3>
<p>If GPT-4 was like a <strong>junior dev who needed hand-holding</strong>, GPT-5 feels more like a <strong>tech lead</strong> — one who thinks about scalability, security, and long-term impact before writing a single line of code.</p>
<p>For developers, this means less micromanaging, fewer corrections, and more <strong>ready-to-deploy</strong> results.</p>
]]></content:encoded></item><item><title><![CDATA[http-status-toolkit : A Lightweight, TypeScript-Friendly Alternative to http-status-codes]]></title><description><![CDATA[In my backend projects, I got tired of constantly writing raw status code numbers like:
res.status(200)
res.status(404)

It works — but it's not expressive. And honestly, it makes code harder to read and maintain over time. Like many developers, I wa...]]></description><link>https://blog.rashedin.dev/http-status-toolkit-a-lightweight-typescript-friendly-alternative-to-http-status-codes</link><guid isPermaLink="true">https://blog.rashedin.dev/http-status-toolkit-a-lightweight-typescript-friendly-alternative-to-http-status-codes</guid><category><![CDATA[#typescript  #node  #http  #npm  #webdev $oppensource]]></category><dc:creator><![CDATA[Rashedin Islam]]></dc:creator><pubDate>Thu, 17 Jul 2025 12:30:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1752755153464/2f1fa746-91bd-44f6-adde-ff22dd035b7e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In my backend projects, I got tired of constantly writing raw status code numbers like:</p>
<pre><code class="lang-ts">res.status(<span class="hljs-number">200</span>)
res.status(<span class="hljs-number">404</span>)
</code></pre>
<p>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.</p>
<p>So I looked into existing solutions.</p>
<hr />
<h2 id="heading-first-i-tried-http-status-codes">🚫 First I Tried <code>http-status-codes</code></h2>
<p><a target="_blank" href="https://www.npmjs.com/package/http-status-codes"><code>http-status-codes</code></a> is a well-known package. With it, you can write:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { StatusCodes } <span class="hljs-keyword">from</span> <span class="hljs-string">"http-status-codes"</span>;
res.status(StatusCodes.OK);
</code></pre>
<p>Much better than hardcoded numbers — but it came with a few drawbacks:</p>
<ul>
<li>❌ No ESM support  </li>
<li>❌ No localization  </li>
<li>❌ No detailed reason phrases  </li>
<li>❌ Separate type definitions (<code>@types/http-status-codes</code>)  </li>
<li>❌ Slightly bloated — 12+ KB minified</li>
</ul>
<p>It didn’t quite solve my problems. So I kept looking.</p>
<hr />
<h2 id="heading-then-i-tried-http-status">😐 Then I Tried <code>http-status</code></h2>
<p><a target="_blank" href="https://www.npmjs.com/package/http-status"><code>http-status</code></a> is another popular choice. It <em>does</em> support both CommonJS and ESM out of the box — nice. But it still had some limitations:</p>
<ul>
<li>❌ No localization or i18n support  </li>
<li>❌ Only short, generic messages  </li>
<li>❌ No detailed descriptions for each code  </li>
<li>❌ Lacks modern TypeScript typings  </li>
<li>❌ Not tree-shakable  </li>
</ul>
<p>So again — better than nothing, but not enough.</p>
<hr />
<h2 id="heading-so-i-built-http-status-toolkit">✅ So I Built <code>http-status-toolkit</code></h2>
<p>I created <a target="_blank" href="https://www.npmjs.com/package/http-status-toolkit"><code>http-status-toolkit</code></a> to solve all of the above. It’s modern, lightweight, and built for <strong>real-world developer needs</strong>.</p>
<p>Here’s what it offers:</p>
<ul>
<li>✅ <strong>TypeScript-first</strong> with full type safety and autocompletion  </li>
<li>✅ <strong>ESM and CommonJS support</strong>  </li>
<li>✅ <strong>Short + detailed</strong> human-readable messages  </li>
<li>✅ <strong>Localization support</strong> in 10+ languages  </li>
<li>✅ <strong>Tree-shakable</strong> and subpath exportable  </li>
<li>✅ Built with <a target="_blank" href="https://github.com/egoist/tsup">tsup</a> for clean, modern builds  </li>
<li>✅ Extremely lightweight: <strong>~4.1 KB minified / ~2.2 KB gzipped</strong></li>
</ul>
<hr />
<h2 id="heading-example-usage">🧪 Example Usage</h2>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { StatusCodes, getStatusMessage } <span class="hljs-keyword">from</span> <span class="hljs-string">"http-status-toolkit"</span>;

<span class="hljs-built_in">console</span>.log(StatusCodes.OK); 
<span class="hljs-comment">// 200</span>

<span class="hljs-built_in">console</span>.log(getStatusMessage(StatusCodes.NOT_FOUND)); 
<span class="hljs-comment">// "Not Found"</span>

<span class="hljs-comment">// Detailed message</span>
<span class="hljs-keyword">import</span> DetailedMessages <span class="hljs-keyword">from</span> <span class="hljs-string">"http-status-toolkit/messages-detailed"</span>;
<span class="hljs-built_in">console</span>.log(getStatusMessage(StatusCodes.NOT_FOUND, { variant: DetailedMessages }));
<span class="hljs-comment">// "Not Found: The requested resource could not be found but may be available in the future."</span>

<span class="hljs-comment">// Localized message (Bengali)</span>
<span class="hljs-keyword">import</span> BengaliMessages <span class="hljs-keyword">from</span> <span class="hljs-string">'http-status-toolkit/messages-bn'</span>;
<span class="hljs-built_in">console</span>.log(getStatusMessage(StatusCodes.NOT_FOUND, { variant: BengaliMessages }));
<span class="hljs-comment">// Output: (Not Found message in Bengali)</span>
</code></pre>
<hr />
<h2 id="heading-feature-comparison">📊 Feature Comparison</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td><code>http-status-codes</code></td><td><code>http-status</code></td><td><code>http-status-toolkit</code></td></tr>
</thead>
<tbody>
<tr>
<td>ESM Support</td><td>❌ No</td><td>✅ Yes</td><td>✅ Yes</td></tr>
<tr>
<td>CommonJS Support</td><td>✅ Yes</td><td>✅ Yes</td><td>✅ Yes</td></tr>
<tr>
<td>TypeScript Support</td><td>❌ (via @types)</td><td>✅ Partial</td><td>✅ Full</td></tr>
<tr>
<td>Localization</td><td>❌ No</td><td>❌ No</td><td>✅ Yes (10+ languages)</td></tr>
<tr>
<td>Short Messages</td><td>✅ Yes</td><td>✅ Yes</td><td>✅ Yes</td></tr>
<tr>
<td>Detailed Messages</td><td>❌ No</td><td>❌ No</td><td>✅ Yes</td></tr>
<tr>
<td>Tree-shakable</td><td>❌ No</td><td>❌ No</td><td>✅ Yes</td></tr>
<tr>
<td>Minified Bundle Size</td><td>~12.2 KB</td><td>~21.1 KB</td><td>✅ ~4.1 KB</td></tr>
<tr>
<td>Gzipped Bundle Size</td><td>~3.6 KB</td><td>~7.4 KB</td><td>✅ ~2.2 KB</td></tr>
</tbody>
</table>
</div><blockquote>
<p>📦 <strong>Bundle size is based on <a target="_blank" href="https://bundlephobia.com/">Bundlephobia</a></strong></p>
</blockquote>
<hr />
<h2 id="heading-why-it-matters">💡 Why It Matters</h2>
<p><code>http-status-toolkit</code> improves:</p>
<ul>
<li><strong>Readability</strong>: No more <code>res.status(403)</code> — use <code>StatusCodes.FORBIDDEN</code>  </li>
<li><strong>Clarity</strong>: Choose between short, detailed, or localized messages  </li>
<li><strong>Internationalization</strong>: Easily display meaningful error responses in your users' languages  </li>
<li><strong>Developer Experience</strong>: Clean API, tree-shakable, and TypeScript-native</li>
</ul>
<hr />
<h2 id="heading-want-to-explore">🧭 Want to Explore?</h2>
<ul>
<li>🔗 <a target="_blank" href="https://www.npmjs.com/package/http-status-toolkit">View on npm</a>  </li>
<li>💻 <a target="_blank" href="https://github.com/dev-rashedin/http-status-toolkit">View source on GitHub</a>  </li>
<li>🌐 <a target="_blank" href="https://www.rashedin.dev">Visit my portfolio</a></li>
</ul>
<hr />
<p>Built with ❤️ and TypeScript by <a target="_blank" href="https://www.rashedin.dev">Rashedin Islam</a><br />If you find it useful, consider giving it a ⭐ on GitHub.</p>
]]></content:encoded></item><item><title><![CDATA[📦 The History of npm: Why It Was Created and How It Solved JavaScript’s Biggest Problems]]></title><description><![CDATA[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.
But do you know why npm was created in the first place?What problems did it ...]]></description><link>https://blog.rashedin.dev/the-history-of-npm</link><guid isPermaLink="true">https://blog.rashedin.dev/the-history-of-npm</guid><category><![CDATA[npm]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Rashedin Islam]]></dc:creator><pubDate>Tue, 08 Jul 2025 11:32:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1751976500141/6cc6503f-5be8-46ac-ac4e-f44e838d114d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Whether you're just starting out with JavaScript or leading enterprise-grade frontend architecture, you're almost certainly using <code>npm</code> — the Node Package Manager — every day.</p>
<p>But do you know why npm was created in the first place?<br />What problems did it solve?<br />And why did each major version change the way we code?</p>
<p>This post is a deep dive into <strong>npm’s journey</strong>, covering:</p>
<ul>
<li><p>Why it was created</p>
</li>
<li><p>What developer pain points it solved</p>
</li>
<li><p>What each major version introduced, and why</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751900103150/7447e586-97ad-4d4d-9ccb-a8f4e3061b37.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-why-was-npm-created">🌱 Why Was npm Created?</h2>
<p>In 2009, Node.js brought JavaScript to the server — a huge step forward. But there was a serious problem:</p>
<blockquote>
<p>❌ There was <strong>no reliable way</strong> to share and reuse Node.js code across projects.</p>
</blockquote>
<p>Developers were forced to:</p>
<ul>
<li><p>Download ZIP files manually</p>
</li>
<li><p>Copy-paste utility code across projects</p>
</li>
<li><p>Clone GitHub repos without versioning control</p>
</li>
</ul>
<p>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: <strong>npm</strong>.</p>
<hr />
<h2 id="heading-what-problems-did-npm-solve">🛠️ What Problems Did npm Solve?</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>❌ Problem</td><td>✅ npm Solution</td></tr>
</thead>
<tbody>
<tr>
<td>No standard way to install libraries</td><td><code>npm install</code> for easy package management</td></tr>
<tr>
<td>Manually managing dependencies</td><td><code>package.json</code> automates dependency tracking</td></tr>
<tr>
<td>Inconsistent versions across environments</td><td>Later solved with <code>package-lock.json</code></td></tr>
<tr>
<td>Hard to publish/share reusable modules</td><td>Central public registry for packages</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-major-milestones-in-npms-journey">📈 Major Milestones in npm’s Journey</h2>
<p>Let’s walk through npm’s evolution and how each milestone was a direct response to real-world issues.</p>
<hr />
<h3 id="heading-2010-npm-cli-launched">🧱 2010 — npm CLI Launched</h3>
<ul>
<li><p><strong>Problem</strong>: Node.js had no default package manager.</p>
</li>
<li><p><strong>Solution</strong>: Isaac Z. Schlueter built <code>npm</code>, introducing:</p>
<ul>
<li><p>A central <strong>registry</strong></p>
</li>
<li><p>A <strong>CLI tool</strong> (<code>npm install</code>)</p>
</li>
<li><p>A metadata file: <code>package.json</code></p>
</li>
</ul>
</li>
<li><p><strong>Impact</strong>: JavaScript finally had a structured, versioned dependency system.</p>
</li>
</ul>
<hr />
<h3 id="heading-2014-npm-inc-founded">🏢 2014 — npm, Inc. Founded</h3>
<ul>
<li><p><strong>Problem</strong>: npm was growing too fast for one person to manage.</p>
</li>
<li><p><strong>Solution</strong>: Isaac created <strong>npm, Inc.</strong> to manage the ecosystem, registry, and future development.</p>
</li>
<li><p><strong>Impact</strong>: Provided stability, funding, and a business model (free for public, paid for private).</p>
</li>
</ul>
<hr />
<h3 id="heading-2016-the-left-pad-incident">💥 2016 — The <code>left-pad</code> Incident</h3>
<ul>
<li><p><strong>Problem</strong>: A tiny package (<code>left-pad</code>) was unpublished and broke thousands of apps.</p>
</li>
<li><p><strong>Solution</strong>: npm changed its policy — popular packages couldn’t be unpublished easily.</p>
</li>
<li><p><strong>Impact</strong>: Forced the ecosystem to consider the importance of dependency stability.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751900325860/0e036b40-5d76-4428-b176-11fccd59f5cf.png" alt class="image--center mx-auto" /></p>
<hr />
<h3 id="heading-2017-npm-v5-locking-dependencies-with-package-lockjson">📘 2017 — npm v5: Locking Dependencies with <code>package-lock.json</code></h3>
<ul>
<li><p><strong>Problem</strong>: Developers were getting <strong>inconsistent installs</strong> due to semver ranges in <code>package.json</code>.</p>
</li>
<li><p><strong>Solution</strong>: Introduced <code>package-lock.json</code>:</p>
<ul>
<li><p>Locks exact versions of every dependency</p>
</li>
<li><p>Ensures <strong>repeatable installs</strong> on any machine</p>
</li>
</ul>
</li>
<li><p><strong>Impact</strong>: Faster CI builds, consistent production environments, and easier debugging.</p>
</li>
</ul>
<hr />
<h3 id="heading-2018-npm-v6-security-comes-first">🔐 2018 — npm v6: Security Comes First</h3>
<ul>
<li><p><strong>Problem</strong>: Security vulnerabilities in packages were going undetected.</p>
</li>
<li><p><strong>Solution</strong>: Introduced <code>npm audit</code>, which:</p>
<ul>
<li><p>Scans installed packages for known issues</p>
</li>
<li><p>Suggests or applies fixes</p>
</li>
</ul>
</li>
<li><p><strong>Impact</strong>: Security became an essential part of the development process.</p>
</li>
</ul>
<hr />
<h3 id="heading-2020-github-acquires-npm">🤝 2020 — GitHub Acquires npm</h3>
<ul>
<li><p><strong>Problem</strong>: npm’s infrastructure and governance were stretched thin.</p>
</li>
<li><p><strong>Solution</strong>: GitHub (owned by Microsoft) acquired npm, promising to keep it open and free.</p>
</li>
<li><p><strong>Impact</strong>:</p>
<ul>
<li><p>Stability for the registry</p>
</li>
<li><p>Deeper CI/CD integrations</p>
</li>
<li><p>Better security workflows via GitHub Actions</p>
</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751903481161/c6086cfc-6117-4f92-b69c-d12393628d4a.png" alt class="image--center mx-auto" /></p>
<hr />
<h3 id="heading-2021-npm-v7-workspaces-and-peer-dependency-fixes">🧰 2021 — npm v7: Workspaces and Peer Dependency Fixes</h3>
<ul>
<li><p><strong>Problem 1</strong>: Managing monorepos was difficult.</p>
</li>
<li><p><strong>Problem 2</strong>: Peer dependency conflicts were common.</p>
</li>
<li><p><strong>Solution</strong>:</p>
<ul>
<li><p>✅ <strong>Workspaces</strong>: Native monorepo support</p>
</li>
<li><p>🔁 <strong>Auto-install peer dependencies</strong></p>
</li>
<li><p>📘 <strong>Lockfile v2</strong>: Smarter resolution and better VCS diffs</p>
</li>
</ul>
</li>
<li><p><strong>Impact</strong>: npm became more reliable for large-scale projects and package ecosystems.</p>
</li>
</ul>
<hr />
<h3 id="heading-2022-npm-v8-speed-amp-audit-ux">⚡ 2022 — npm v8: Speed &amp; Audit UX</h3>
<ul>
<li><p><strong>Problem</strong>: The CLI was slower and audit reports were verbose.</p>
</li>
<li><p><strong>Solution</strong>:</p>
<ul>
<li><p>Enhanced performance and caching</p>
</li>
<li><p>Improved audit reporting UX</p>
</li>
<li><p>Fine-grained configuration options</p>
</li>
</ul>
</li>
<li><p><strong>Impact</strong>: Developers got a faster, cleaner, more configurable CLI experience.</p>
</li>
</ul>
<hr />
<h3 id="heading-20232025-backend-scaling-ci-integration-amp-registry-stability">🔄 2023–2025 — Backend Scaling, CI Integration &amp; Registry Stability</h3>
<ul>
<li><p><strong>Problem</strong>: The registry needed to scale, CI/CD needed tighter npm integration.</p>
</li>
<li><p><strong>Solution</strong>:</p>
<ul>
<li><p>Global <strong>edge caching</strong> for faster package fetches</p>
</li>
<li><p>Smarter vulnerability resolution in <code>npm audit</code></p>
</li>
<li><p>Tighter GitHub Actions integration for <code>npm publish</code>, <code>audit</code>, and scoped packages</p>
</li>
</ul>
</li>
<li><p><strong>Impact</strong>: npm became more stable, CI-friendly, and scalable — without introducing another major CLI version.</p>
</li>
</ul>
<hr />
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751902847670/0466e9d9-f9f4-42ac-9190-2c4a4dcac2f1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-summary-table-problems-vs-solutions">🔍 <code>Summary Table: Problems vs. Solutions</code></h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td><code>Year</code></td><td><code>Version / Event</code></td><td><code>Problem</code></td><td><code>Solution</code></td></tr>
</thead>
<tbody>
<tr>
<td><code>2010</code></td><td><code>npm CLI</code></td><td><code>No standard package manager</code></td><td><code>Introduced CLI + registry + package.json</code></td></tr>
<tr>
<td><code>2014</code></td><td><code>npm, Inc.</code></td><td><code>No long-term governance</code></td><td><code>Company to manage ecosystem</code></td></tr>
<tr>
<td><code>2016</code></td><td><code>Left-pad Incident</code></td><td><code>Uncontrolled unpublishing</code></td><td><code>Policy restrictions to protect dependencies</code></td></tr>
<tr>
<td><code>2017</code></td><td><code>v5</code></td><td><code>Inconsistent installs</code></td><td><code>Introduced package-lock.json</code></td></tr>
<tr>
<td><code>2018</code></td><td><code>v6</code></td><td><code>Security vulnerabilities</code></td><td><code>Introduced npm audit</code></td></tr>
<tr>
<td><code>2020</code></td><td><code>GitHub Acquisition</code></td><td><code>Infrastructure scaling, trust issues</code></td><td><code>GitHub backing and registry modernization</code></td></tr>
<tr>
<td><code>2021</code></td><td><code>v7</code></td><td><code>Monorepo &amp; peer dependency issues</code></td><td><code>Workspaces + peer auto-install + lockfile v2</code></td></tr>
<tr>
<td><code>2022</code></td><td><code>v8</code></td><td><code>CLI speed and audit UX</code></td><td><code>Faster installs, better audit output</code></td></tr>
<tr>
<td><code>2023–25</code></td><td><code>Registry Upgrades</code></td><td><code>CI/DevOps integration and scaling</code></td><td><code>Backend optimization + GitHub integration</code></td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-why-this-matters"><code>🧠 Why This Matters</code></h2>
<p>Every version of npm was created to solve real, developer-facing problems — from code sharing and dependency hell to security and monorepo complexity.</p>
<p>If you understand <strong>why</strong> a tool evolved the way it did, you'll not only use it better — you'll build better systems with it.</p>
<blockquote>
<p>npm isn’t just a package manager — it’s the backbone of the modern JavaScript ecosystem.</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Say Goodbye to Try-Catch: Smarter Async Error Handling in Express]]></title><description><![CDATA[When building a backend with Node.js and Express, we're likely using async/await to handle things like database queries or API calls.
But there’s a catch — if we don’t handle errors properly, our server can crash or behave unpredictably. 😬
In this p...]]></description><link>https://blog.rashedin.dev/smart-async-error-handler-in-express</link><guid isPermaLink="true">https://blog.rashedin.dev/smart-async-error-handler-in-express</guid><category><![CDATA[Learn how to handle async/await errors in Express.js using custom handlers, npm libraries, and global middleware. Say goodbye to messy try-catch blocks!]]></category><category><![CDATA[Express]]></category><category><![CDATA[backend]]></category><category><![CDATA[APIs]]></category><category><![CDATA[async error]]></category><category><![CDATA[express-error-toolkit]]></category><dc:creator><![CDATA[Rashedin Islam]]></dc:creator><pubDate>Tue, 01 Jul 2025 14:50:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1751380842628/636edffb-6f04-4ac9-ac7a-923d4d86fdd5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When building a backend with Node.js and Express, we're likely using <code>async/await</code> to handle things like database queries or API calls.</p>
<p>But there’s a catch — if we don’t handle errors properly, our server can <strong>crash</strong> or behave <strong>unpredictably</strong>. 😬</p>
<p>In this post, you'll learn a <strong>clean, scalable</strong> way to handle async errors in Express:</p>
<ul>
<li>Why <code>try-catch</code> in every route is painful  </li>
<li>How to fix it with a reusable <code>asyncHandler()</code>  </li>
<li>How to simplify this using external libraries  </li>
<li>How to use my own package: <strong>express-error-toolkit</strong>  </li>
<li>How to define custom error classes  </li>
<li>And how to set up a global error handler  </li>
</ul>
<hr />
<h2 id="heading-the-problem-with-try-catch-everywhere">🚨 The Problem With Try-Catch Everywhere</h2>
<p>Here’s how we usually handle errors:</p>
<pre><code class="lang-js">app.get(<span class="hljs-string">'/api/users/:id'</span>, <span class="hljs-keyword">async</span> (req, res, next) =&gt; {
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">const</span> user = <span class="hljs-keyword">await</span> User.findById(req.params.id);
    <span class="hljs-keyword">if</span> (!user) <span class="hljs-keyword">return</span> res.status(<span class="hljs-number">404</span>).json({ <span class="hljs-attr">message</span>: <span class="hljs-string">'User not found'</span> });
    res.json(user);
  } <span class="hljs-keyword">catch</span> (error) {
    next(error);
  }
});
</code></pre>
<p>Repeating this in every route is:</p>
<ul>
<li>Redundant  </li>
<li>Ugly  </li>
<li>Easy to forget  </li>
</ul>
<p>Let’s fix that.</p>
<hr />
<h2 id="heading-option-1-write-a-custom-asynchandler">✅ Option 1: Write a Custom <code>asyncHandler</code></h2>
<pre><code class="lang-js"><span class="hljs-comment">// utils/asyncHandler.js</span>
<span class="hljs-keyword">const</span> asyncHandler = <span class="hljs-function">(<span class="hljs-params">fn</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> <span class="hljs-function">(<span class="hljs-params">req, res, next</span>) =&gt;</span> {
    <span class="hljs-built_in">Promise</span>.resolve(fn(req, res, next)).catch(next);
  };
};

<span class="hljs-built_in">module</span>.exports = asyncHandler;
</code></pre>
<p>Use it like this:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> asyncHandler = <span class="hljs-built_in">require</span>(<span class="hljs-string">'../utils/asyncHandler'</span>);

app.get(<span class="hljs-string">'/api/users/:id'</span>, asyncHandler(<span class="hljs-keyword">async</span> (req, res) =&gt; {
  <span class="hljs-keyword">const</span> user = <span class="hljs-keyword">await</span> User.findById(req.params.id);
  <span class="hljs-keyword">if</span> (!user) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'User not found'</span>);
  res.json(user);
}));
</code></pre>
<p>Clean. Reusable. No <code>try-catch</code>.</p>
<hr />
<h2 id="heading-option-2-use-a-library-highly-recommended">📦 Option 2: Use a Library (Highly Recommended)</h2>
<h3 id="heading-express-error-toolkit-view-on-npmhttpswwwnpmjscompackageexpress-error-toolkit">🔹 express-error-toolkit — <a target="_blank" href="https://www.npmjs.com/package/express-error-toolkit">View on npm</a></h3>
<p><img src="https://img.shields.io/npm/v/express-error-toolkit" alt="npm" />
<img src="https://img.shields.io/npm/dm/express-error-toolkit" alt="downloads" /></p>
<p>I built this package to make error handling in Express apps much easier. It includes:</p>
<ul>
<li>An <code>asyncHandler()</code> function  </li>
<li>Predefined error classes (<code>NotFoundError</code>, <code>BadRequestError</code>, etc.)  </li>
<li>A global error-handling middleware  </li>
<li>Clean stack traces in development</li>
</ul>
<h4 id="heading-install">Install</h4>
<pre><code class="lang-bash">npm install express-error-toolkit
</code></pre>
<h4 id="heading-use">Use</h4>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> { asyncHandler } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express-error-toolkit'</span>);

app.get(<span class="hljs-string">'/api/users/:id'</span>, asyncHandler(<span class="hljs-keyword">async</span> (req, res) =&gt; {
  <span class="hljs-keyword">const</span> user = <span class="hljs-keyword">await</span> User.findById(req.params.id);
  <span class="hljs-keyword">if</span> (!user) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'User not found'</span>);
  res.json(user);
}));
</code></pre>
<hr />
<h2 id="heading-define-custom-error-classes">🧱 Define Custom Error Classes</h2>
<p>If you don’t use a package, you can define your own:</p>
<pre><code class="lang-js"><span class="hljs-comment">// utils/ApiError.js</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ApiError</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Error</span> </span>{
  <span class="hljs-keyword">constructor</span>(statusCode, message) {
    <span class="hljs-built_in">super</span>(message);
    <span class="hljs-built_in">this</span>.statusCode = statusCode;
    <span class="hljs-built_in">Error</span>.captureStackTrace(<span class="hljs-built_in">this</span>, <span class="hljs-built_in">this</span>.constructor);
  }
}

<span class="hljs-built_in">module</span>.exports = ApiError;
</code></pre>
<p>Usage:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> ApiError = <span class="hljs-built_in">require</span>(<span class="hljs-string">'../utils/ApiError'</span>);

<span class="hljs-keyword">if</span> (!user) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> ApiError(<span class="hljs-number">404</span>, <span class="hljs-string">'User not found'</span>);
</code></pre>
<h3 id="heading-or-use-express-error-toolkits-built-in-errors">Or use express-error-toolkit’s built-in errors</h3>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> { NotFoundError } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express-error-toolkit'</span>);

<span class="hljs-keyword">if</span> (!user) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> NotFoundError(<span class="hljs-string">'User not found'</span>);
</code></pre>
<hr />
<h2 id="heading-global-error-handling-middleware">🌍 Global Error-Handling Middleware</h2>
<p>Add this at the <strong>end</strong> of your middleware chain:</p>
<pre><code class="lang-js">app.use(<span class="hljs-function">(<span class="hljs-params">err, req, res, next</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> status = err.statusCode || <span class="hljs-number">500</span>;
  <span class="hljs-keyword">const</span> message = err.message || <span class="hljs-string">'Internal Server Error'</span>;

  res.status(status).json({
    <span class="hljs-attr">success</span>: <span class="hljs-literal">false</span>,
    message,
    <span class="hljs-attr">stack</span>: process.env.NODE_ENV === <span class="hljs-string">'production'</span> ? <span class="hljs-literal">null</span> : err.stack,
  });
});
</code></pre>
<h3 id="heading-or-use-express-error-toolkits-built-in-handler">Or use express-error-toolkit’s built-in handler:</h3>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> { globalErrorHandler } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express-error-toolkit'</span>);

app.use(globalErrorHandler);
</code></pre>
<hr />
<h2 id="heading-full-example">🧪 Full Example</h2>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);
<span class="hljs-keyword">const</span> {
  NotFoundError,
  asyncHandler,
  globalErrorHandler,
} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express-error-toolkit'</span>);

<span class="hljs-keyword">const</span> app = express();
app.use(express.json());

app.get(<span class="hljs-string">'/api/users/:id'</span>, asyncHandler(<span class="hljs-keyword">async</span> (req, res) =&gt; {
  <span class="hljs-keyword">const</span> user = <span class="hljs-keyword">await</span> User.findById(req.params.id);
  <span class="hljs-keyword">if</span> (!user) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> NotFoundError(<span class="hljs-string">'User not found'</span>);
  res.json(user);
}));

app.use(globalErrorHandler);

app.listen(<span class="hljs-number">3000</span>, <span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Server running on port 3000'</span>));
</code></pre>
<hr />
<h2 id="heading-final-thoughts">🧠 Final Thoughts</h2>
<p>✅ Avoid <code>try-catch</code> in every route using <code>asyncHandler</code><br />📦 Use <strong>express-error-toolkit</strong> for a full-featured, clean setup<br />🧱 Throw meaningful errors with custom classes<br />🌍 Catch and format all errors in one global middleware</p>
<p>Follow this approach and your Express backend will be clean, scalable, and production-ready. 🚀</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Type Guards in TypeScript: Write Safer, Smarter Code]]></title><description><![CDATA[As we dive deeper into TypeScript, one powerful feature we can use to improve our code is Type Guards. But what exactly are they?

What are Type Guards? 🤔
In TypeScript, a type guard is a special function that narrows down the type of a variable wit...]]></description><link>https://blog.rashedin.dev/type-guards-in-ts</link><guid isPermaLink="true">https://blog.rashedin.dev/type-guards-in-ts</guid><category><![CDATA[#TypeScript #WebDevelopment #CodeQuality #TypeSafety #CodingTips]]></category><dc:creator><![CDATA[Rashedin Islam]]></dc:creator><pubDate>Sun, 29 Jun 2025 16:00:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1751208220255/21891043-41c1-4515-9a92-4bb1c809dfd7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As we dive deeper into TypeScript, one powerful feature we can use to improve our code is <strong>Type Guards</strong>. But what exactly are they?</p>
<hr />
<h3 id="heading-what-are-type-guards">What are Type Guards? 🤔</h3>
<p>In TypeScript, a <strong>type guard</strong> is a special function that narrows down the type of a variable within a certain scope. This helps us safely perform operations on different types of data, making our code more predictable and less error-prone.</p>
<hr />
<h3 id="heading-why-use-type-guards">Why Use Type Guards? 🤖</h3>
<p>Imagine you have a variable that could be of multiple types (like a string or number), and you need to perform specific actions for each type. A type guard helps TypeScript <strong>understand</strong> the exact type at runtime, allowing you to safely access properties or methods.</p>
<hr />
<h3 id="heading-example-checking-for-a-string">Example: Checking for a String 📝</h3>
<p>Here’s how you can write a simple custom type guard to check if a value is a string:</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isString</span>(<span class="hljs-params">value: unknown</span>): <span class="hljs-title">value</span> <span class="hljs-title">is</span> <span class="hljs-title">string</span> </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">typeof</span> value === <span class="hljs-string">'string'</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">printUpperCase</span>(<span class="hljs-params">value: unknown</span>): <span class="hljs-title">void</span> </span>{
  <span class="hljs-keyword">if</span> (isString(value)) {
    <span class="hljs-built_in">console</span>.log(value.toUpperCase());  <span class="hljs-comment">// Safe to use string methods</span>
  } <span class="hljs-keyword">else</span> {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Not a string!'</span>);
  }
}
</code></pre>
<p>In this example, the <code>isString</code> function helps TypeScript know that <code>value</code> is a string inside the <code>if</code> block, so we can safely call <code>toUpperCase()</code>.</p>
<hr />
<h3 id="heading-benefits-of-using-type-guards">Benefits of Using Type Guards 🛠️</h3>
<ul>
<li><p><strong>Increased Type Safety:</strong> Type guards help us ensure we’re working with the correct type.</p>
</li>
<li><p><strong>Cleaner Code:</strong> Avoids unnecessary checks scattered throughout your codebase.</p>
</li>
<li><p><strong>Better Autocomplete:</strong> TypeScript can give you more accurate suggestions when it knows the type of your variable.</p>
</li>
</ul>
<hr />
<h3 id="heading-wrap-up">Wrap Up ✨</h3>
<p>Using type guards makes our TypeScript code smarter and safer by allowing TypeScript to know more about the types we're working with. It's a small concept but can have a big impact on code quality!</p>
<p>🔗 Dive into TypeScript type guards and start using them to improve your development workflow. Happy coding! 💻</p>
<hr />
<p>#TypeScript #WebDevelopment #CodeQuality #TypeSafety #CodingTips</p>
]]></content:encoded></item></channel></rss>