<?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: Saleh Khatri</title>
    <description>The latest articles on DEV Community by Saleh Khatri (@salehkhatri).</description>
    <link>https://dev.to/salehkhatri</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%2F2705834%2F04d8878c-1aec-449c-9668-13d1b89fd7a7.jpeg</url>
      <title>DEV Community: Saleh Khatri</title>
      <link>https://dev.to/salehkhatri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/salehkhatri"/>
    <language>en</language>
    <item>
      <title>Streamline Your API Workflow with 2 Essential Postman Configurations</title>
      <dc:creator>Saleh Khatri</dc:creator>
      <pubDate>Sun, 26 Jan 2025 11:43:02 +0000</pubDate>
      <link>https://dev.to/salehkhatri/streamline-your-api-workflow-with-2-essential-postman-configurations-39c2</link>
      <guid>https://dev.to/salehkhatri/streamline-your-api-workflow-with-2-essential-postman-configurations-39c2</guid>
      <description>&lt;p&gt;Postman is a powerful tool for API development, but small configuration tweaks can turn it into a &lt;strong&gt;productivity powerhouse&lt;/strong&gt;. Let’s explore two setups that’ll save you from repetitive tasks: &lt;strong&gt;auto-switching environments&lt;/strong&gt; and &lt;strong&gt;hands-free token management&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Auto-Switch Between Dev and Prod Environments
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;No more manual URL changes!&lt;/em&gt;  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Problem&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Switching between &lt;code&gt;localhost&lt;/code&gt; (development) and your live production API endpoint? Manually updating the &lt;code&gt;BASE_URL&lt;/code&gt; every time is error-prone and tedious.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Solution&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Add a &lt;strong&gt;pre-request script&lt;/strong&gt; to your Postman collection to auto-detect the environment and set the correct &lt;code&gt;BASE_URL&lt;/code&gt;.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Setup Steps&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. Create Environment Variables&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Open Postman → Click the &lt;strong&gt;"Environments"&lt;/strong&gt; tab (left sidebar).
&lt;/li&gt;
&lt;li&gt;Create a new environment (e.g., &lt;code&gt;My Project&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;Add two variables:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ENV&lt;/code&gt;: Set value to &lt;code&gt;dev&lt;/code&gt; or &lt;code&gt;prod&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;BASE_URL&lt;/code&gt;: Add a placeholder value like &lt;code&gt;http://localhost&lt;/code&gt; &lt;em&gt;(script will override this)&lt;/em&gt; &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%2Fndmae5n5a9cd81trgi83.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%2Fndmae5n5a9cd81trgi83.png" alt="Variables_setup" width="800" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;2. Add the Pre-Request Script&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Go to your Collection → Go to Scripts tab → Click the "Pre-request" tab.&lt;/li&gt;
&lt;li&gt;Paste this code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Get environment (default to 'dev' if not set)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;environment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&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="s2"&gt;ENV&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dev&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Set BASE_URL dynamically&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dev&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;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;BASE_URL&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://localhost:5000&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="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;prod&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;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;BASE_URL&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://lfsms-backend.onrender.com&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="k"&gt;else&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="s2"&gt;Invalid environment. Set ENV to 'dev' or 'prod'.&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;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="s2"&gt;`🌐 Environment set to: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Ftmnord42zwkaccf5eoyx.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%2Ftmnord42zwkaccf5eoyx.png" alt="Pre-Script image" width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;How to Use BASE_URL in Your Requests&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once the &lt;code&gt;BASE_URL&lt;/code&gt; variable is set, you can reuse it across &lt;strong&gt;all requests&lt;/strong&gt; in your collection. Here’s how:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When creating a request, instead of typing the full URL (e.g., &lt;code&gt;http://localhost:5000/api/login&lt;/code&gt;), use &lt;code&gt;{{BASE_URL}}&lt;/code&gt; as the base.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;{{BASE_URL}}/api/v1/auth/login&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This dynamically resolves to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://localhost:5000/api/v1/auth/login" rel="noopener noreferrer"&gt;http://localhost:5000/api/v1/auth/login&lt;/a&gt; in dev&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://api.example.com/api/v1/auth/login" rel="noopener noreferrer"&gt;https://api.example.com/api/v1/auth/login&lt;/a&gt; in prod&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%2Ffrezrs0t1zyw5bxn67lj.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%2Ffrezrs0t1zyw5bxn67lj.png" alt="BASE_URL usage" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Why This Works&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The script dynamically updates &lt;code&gt;BASE_URL&lt;/code&gt; based on your &lt;code&gt;ENV&lt;/code&gt; variable.&lt;/li&gt;
&lt;li&gt;Use the same request structure across environments – no more manual edits!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Automatically Save JWT Tokens After Login
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;No more manual token copying!&lt;/em&gt;  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Problem&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;After logging in, you need to manually copy the JWT token from the response and paste it into headers for authenticated requests. This repetitive work slows you down!  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Solution&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Add a &lt;strong&gt;script&lt;/strong&gt; to your authentication request to auto-save the token to environment variables.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Setup Steps&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. Add a Script to Your Auth Request&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Open your login/sign-in request in Postman.
&lt;/li&gt;
&lt;li&gt;Go to the &lt;strong&gt;"Script"&lt;/strong&gt; tab.
&lt;/li&gt;
&lt;li&gt;Paste this code in Post-response Scripts:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;responseData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response&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="c1"&gt;// Replace 'data.token' with your API's actual token path&lt;/span&gt;
  &lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TOKEN&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;responseData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Token path&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="s2"&gt;🔑 Token saved automatically!&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="k"&gt;else&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;⚠️ Login failed: Check credentials&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;p&gt;If your API's response structure is different (e.g., &lt;code&gt;responseData.access_token&lt;/code&gt; or &lt;code&gt;responseData.token&lt;/code&gt;), modify the script accordingly&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%2Fh7jzs88bgfqn8ggud9n1.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%2Fh7jzs88bgfqn8ggud9n1.png" alt="Auth Script" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Customize for Your API&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If your token isn’t in &lt;code&gt;responseData.data.token&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check your API response in Postman’s "&lt;strong&gt;Response&lt;/strong&gt;" panel&lt;/li&gt;
&lt;li&gt;Adjust the path in the script. Examples:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// If your token is directly in the root:&lt;/span&gt;
&lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TOKEN&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;responseData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// If nested under an "auth" object:&lt;/span&gt;
&lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TOKEN&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;responseData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3. Use the Token in Other Requests:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In authenticated requests, reference &lt;code&gt;{{TOKEN}}&lt;/code&gt; in headers&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%2Fiedk9rlx8n0nde17e873.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%2Fiedk9rlx8n0nde17e873.png" alt="USE_TOKEN" width="800" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Why This Works&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The script extracts the token/role from your login response’s JSON structure&lt;/li&gt;
&lt;li&gt;Works for any &lt;strong&gt;API format&lt;/strong&gt; – just update the JSON path to match your response&lt;/li&gt;
&lt;li&gt;No more manual copy-pasting!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Let’s Build Better APIs Together!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’m always curious to see how developers streamline their workflows and solve API challenges. If you tried this setup, ran into issues, or have your own Postman hacks to share, let’s chat!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📬 Find me here:&lt;/strong&gt;&lt;br&gt;
🐦 Twitter: &lt;a href="https://x.com/salehdotdev" rel="noopener noreferrer"&gt;@salehdotdev&lt;/a&gt;&lt;br&gt;&lt;br&gt;
🌐 Portfolio: &lt;a href="http://salehkhatri.tech/" rel="noopener noreferrer"&gt;salehkhatri.tech&lt;/a&gt;&lt;br&gt;&lt;br&gt;
📧 Email: &lt;a href="//salehkhatri29@gmail.com"&gt;salehkhatri29@gmail.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Follow for more:&lt;/strong&gt;&lt;br&gt;
I regularly share tips on Postman automation, API development, and backend best practices. Let’s turn tedious tasks into elegant solutions!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stuck with configurations?&lt;/strong&gt;&lt;br&gt;
If you’re wrestling with environment variables or scripting quirks, reach out! I’m happy to help troubleshoot or brainstorm ideas.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Remember: Great tools aren’t just about power – they’re about making your dev life simpler. Keep iterating, keep shipping! 🚀&lt;/em&gt;&lt;/p&gt;

</description>
      <category>postman</category>
      <category>api</category>
      <category>postmanapi</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Level Up Your Architecture Game with Monolithic Modular - It's Not What You Think</title>
      <dc:creator>Saleh Khatri</dc:creator>
      <pubDate>Wed, 15 Jan 2025 07:16:09 +0000</pubDate>
      <link>https://dev.to/salehkhatri/level-up-your-architecture-game-with-monolithic-modular-its-not-what-you-think-25f5</link>
      <guid>https://dev.to/salehkhatri/level-up-your-architecture-game-with-monolithic-modular-its-not-what-you-think-25f5</guid>
      <description>&lt;p&gt;Ever had that moment where your codebase feels like a teenager's room - technically organized but somehow still a mess? That was me six months ago. That's when i came across a thing called as &lt;strong&gt;Monolithic Modular Architecture&lt;/strong&gt;. Despite its boring name, this approach changed everything. &lt;/p&gt;

&lt;p&gt;You might be thinking "Oh great, another architecture article..." but I promise you this isn't about preaching the "one true way.". Instead, I want to share how this approach helped me sleep better, and actually enjoy working with our codebase again.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Monolithic Modular architecture?
&lt;/h2&gt;

&lt;p&gt;Imagine you're building a house. Traditional monoliths are like having one giant room where everything happens (cooking, sleeping, working - chaos!). On the flip side, microservices are like having separate tiny houses for each activity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monolithic Modular?&lt;/strong&gt;&lt;br&gt;
 It's like having one house (easier to maintain and secure) but with well-defined rooms that each serve their purpose (kitchen for cooking, bedroom for sleeping - you get the idea). Each "room" (module) has its own rules and purpose, but they're all under one roof.&lt;/p&gt;

&lt;p&gt;In code terms, it looks like this:&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%2F4w1oj7cz1juhv0extrct.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%2F4w1oj7cz1juhv0extrct.png" alt="Basic example of MMA" width="300" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The secret sauce? Each module:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Has its own clear boundary (like walls in our house)&lt;/li&gt;
&lt;li&gt;Manages its own specific business logic&lt;/li&gt;
&lt;li&gt;Can talk to other modules through well-defined doorways (interfaces)&lt;/li&gt;
&lt;li&gt;Shares some common utilities (like how all rooms share the same plumbing)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But here's the best part - at the end of the day, you deploy everything together as one unit. No need to orchestrate multiple services or worry about complex network communication. It's modular where it matters (in your code) and monolithic where it helps (in deployment and operation).&lt;/p&gt;

&lt;h2&gt;
  
  
  Real Project Structure in Action 👀
&lt;/h2&gt;

&lt;p&gt;Now that we understand the concept, let me show you how we implement this in practice with a real-world example. I'll use a typical e-commerce backend API to demonstrate.&lt;/p&gt;

&lt;p&gt;Let me show you how this looks in an actual project. Here's a screenshot from VS Code that'll make things crystal clear:&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%2F7mo7r5w2euvkf80r0olq.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%2F7mo7r5w2euvkf80r0olq.png" alt="Project structure in an actual ecommerce api" width="319" height="818"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Key Parts Explained🎯
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. The &lt;code&gt;modules&lt;/code&gt; Directory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each module is a self-contained feature with its own:&lt;br&gt;
&lt;code&gt;controller.js&lt;/code&gt; (🔧 handles HTTP requests)&lt;br&gt;
&lt;code&gt;service.js&lt;/code&gt; (⚙️ business logic)&lt;br&gt;
&lt;code&gt;routes.js&lt;/code&gt; (🛣️ API endpoints)&lt;br&gt;
&lt;code&gt;index.js&lt;/code&gt; (📦 public interface)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Supporting Cast&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;middlewares/&lt;/code&gt;: Shared middleware like auth checks and error handlers&lt;br&gt;
&lt;code&gt;utils/&lt;/code&gt;: Common utilities (JWT handling, error classes)&lt;br&gt;
&lt;code&gt;prisma/&lt;/code&gt;: Database stuff kept neat and tidy&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Structure Rocks💡
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Easy to Navigate: Need to fix an auth bug? Just dive into the auth module. Everything you need is right there.&lt;/li&gt;
&lt;li&gt;New Developer Friendly: The structure tells the story. You can understand how the app works just by looking at the folder structure.&lt;/li&gt;
&lt;li&gt;Scalable: Adding a new feature? Create a new module folder, and you're good to go. No need to touch existing code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common Gotchas &amp;amp; How to Handle Them 🚧
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Module Boundaries&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't Share Database Models Directly: Instead of importing Prisma models everywhere, expose specific methods through your service&lt;/li&gt;
&lt;li&gt;Avoid Circular Dependencies: If modules A and B need each other, that's a red flag. Usually means you need to rethink your boundaries&lt;/li&gt;
&lt;li&gt;Keep Utils Actually Useful: Don't turn your &lt;code&gt;utils&lt;/code&gt; folder into a dumping ground. If it's specific to a module, keep it in that module&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Dependency Management Tips&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Module Index Files Wisely: Export only what other modules need. Not everything needs to be public&lt;/li&gt;
&lt;li&gt;Dependency Injection is Your Friend: Pass services through constructors-makes testing easier and dependencies clear&lt;/li&gt;
&lt;li&gt;Watch for Growing Modules: If a module is getting too big, it might need to be split. Size isn't just about lines of code - it's about responsibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Practical Advice&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start with broader modules and split when needed - don't over-optimize early&lt;/li&gt;
&lt;li&gt;Keep module names business-focused, not technical (prefer &lt;code&gt;inventory&lt;/code&gt; over &lt;code&gt;data-management&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Document module boundaries in README files - your future self will thank you&lt;/li&gt;
&lt;li&gt;Use consistent file naming across modules - makes the codebase feel professional&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion 🎯
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;When to Consider This Pattern&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your monolith is getting messy, but microservices feel like overkill&lt;/li&gt;
&lt;li&gt;You want clean code organization without deployment complexity&lt;/li&gt;
&lt;li&gt;Your team needs clear boundaries but wants to keep things simple&lt;/li&gt;
&lt;li&gt;You're building something that might grow but don't want to over-engineer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Results After Adoption&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;50% faster onboarding for new team members&lt;/li&gt;
&lt;li&gt;Easier to locate and fix bugs&lt;/li&gt;
&lt;li&gt;Better test coverage (modules are naturally more testable)&lt;/li&gt;
&lt;li&gt;Happier developers (seriously, no more "where does this code go?" debates)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Journey Continues 🚀
&lt;/h2&gt;

&lt;p&gt;This pattern has transformed how I think about architecture. It's not just about organizing code - it's about making development enjoyable and maintenance manageable.&lt;/p&gt;

&lt;p&gt;I'm always excited to hear how others are structuring their applications and learn from different approaches. If you found this helpful or have your own experiences to share, let's connect!&lt;/p&gt;

&lt;p&gt;Find me at:&lt;/p&gt;

&lt;p&gt;🐦 Twitter: &lt;a href="https://x.com/salehdotdev" rel="noopener noreferrer"&gt;@salehdotdev&lt;/a&gt;&lt;br&gt;&lt;br&gt;
🌐 Portfolio: &lt;a href="http://salehkhatri.tech/" rel="noopener noreferrer"&gt;salehkhatri.tech&lt;/a&gt;&lt;br&gt;&lt;br&gt;
📧 Email: &lt;a href="//salehkhatri29@gmail.com"&gt;salehkhatri29@gmail.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow me for more content about JavaScript, Node.js, and software architecture. I share regular tips and insights about building better applications!&lt;/p&gt;

&lt;p&gt;Want to dive deeper into any aspect or need help implementing this in your project? Feel free to reach out - I'm always happy to help fellow developers level up their architecture game! 🎮&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Remember: Good architecture isn't about following rules blindly - it's about making development enjoyable and maintenance manageable. Keep building awesome stuff!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>architecture</category>
      <category>development</category>
      <category>microservices</category>
    </item>
  </channel>
</rss>
