<?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>Forem: ADEKOLA Abdwahab</title>
    <description>The latest articles on Forem by ADEKOLA Abdwahab (@codarbind).</description>
    <link>https://forem.com/codarbind</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%2F611910%2F229d707c-57e1-40e1-b374-d9ad9db6a629.jpeg</url>
      <title>Forem: ADEKOLA Abdwahab</title>
      <link>https://forem.com/codarbind</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/codarbind"/>
    <language>en</language>
    <item>
      <title>Sequelize, Postgresql column does not exist Fix</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Mon, 13 Oct 2025 09:33:44 +0000</pubDate>
      <link>https://forem.com/codarbind/sequelize-postgresql-column-does-not-exist-fix-f77</link>
      <guid>https://forem.com/codarbind/sequelize-postgresql-column-does-not-exist-fix-f77</guid>
      <description>&lt;h2&gt;
  
  
  Fixing the “column does not exist” error in Sequelize + PostgreSQL
&lt;/h2&gt;

&lt;p&gt;I woke to a slack message that an endpoint was hitting 500, an my check it was traced to Sequelize / PostgreSQL error, which I was conversant with while using PgAdmin but missed while using literal in Sequelize&lt;/p&gt;

&lt;p&gt;This error:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;column "isavailable" does not exist&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you are facing same issue, you’re not alone — and the fix is surprisingly simple.&lt;/p&gt;

&lt;h3&gt;
  
  
  💡 The cause
&lt;/h3&gt;

&lt;p&gt;When you write raw SQL or Sequelize literals like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;literal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CASE WHEN isAvailable THEN 1 ELSE 0 END&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Postgres interprets &lt;code&gt;isAvailable&lt;/code&gt; as a lowercase identifier (&lt;code&gt;isavailable&lt;/code&gt;) — which doesn’t exist.&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%2F9pntbuf866myc7uoggpe.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%2F9pntbuf866myc7uoggpe.png" alt="My changes to fix the issue" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ The fix
&lt;/h3&gt;

&lt;p&gt;Wrap the column name in &lt;strong&gt;double quotes&lt;/strong&gt; to make it case-sensitive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;literal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CASE WHEN "isAvailable" THEN 1 ELSE 0 END&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Postgres understands that you’re referring to the actual column name exactly as defined.&lt;/p&gt;




&lt;h3&gt;
  
  
  ⚙️ Bonus Tip
&lt;/h3&gt;

&lt;p&gt;To verify what columns really exist in your table, run this in pgAdmin or psql:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;column_name&lt;/span&gt; 
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;information_schema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'property'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ✨ Takeaway
&lt;/h3&gt;

&lt;p&gt;Always remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL lowercases unquoted identifiers.&lt;/li&gt;
&lt;li&gt;Wrapping column names in &lt;code&gt;""&lt;/code&gt; makes them exact and avoids this error.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simple quotes, powerful fix. 💪&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>sequelize</category>
      <category>database</category>
    </item>
    <item>
      <title>When Emails Stopped Sending After Migrating to DigitalOcean</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Sun, 31 Aug 2025 11:10:36 +0000</pubDate>
      <link>https://forem.com/codarbind/when-emails-stopped-sending-after-migrating-to-digitalocean-2kii</link>
      <guid>https://forem.com/codarbind/when-emails-stopped-sending-after-migrating-to-digitalocean-2kii</guid>
      <description>&lt;p&gt;A while ago, I had to move some services from &lt;strong&gt;Render&lt;/strong&gt; to &lt;strong&gt;DigitalOcean Droplets&lt;/strong&gt;. The migration went smoothly—until I noticed something odd.&lt;/p&gt;

&lt;p&gt;Emails weren’t going out.&lt;/p&gt;

&lt;p&gt;Every attempt ended with a &lt;strong&gt;timeout error&lt;/strong&gt;. Frustrating.&lt;/p&gt;

&lt;p&gt;At first, I suspected our email provider. A quick search even revealed a few people complaining about similar issues, so I confidently pointed fingers in that direction and proposed switching providers.&lt;/p&gt;

&lt;p&gt;But then the unexpected happened—&lt;strong&gt;the exact same issue occurred with the new provider.&lt;/strong&gt;&lt;br&gt;
Meanwhile, everything worked perfectly on my local machine.&lt;/p&gt;

&lt;p&gt;That’s when the lightbulb went on.&lt;br&gt;
The issue wasn’t with the providers at all… it was with &lt;strong&gt;DigitalOcean itself.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Real Culprit: Blocked SMTP Ports
&lt;/h2&gt;

&lt;p&gt;After digging deeper, I discovered that DigitalOcean &lt;strong&gt;blocks all popular SMTP ports&lt;/strong&gt; (25, 465, 587, etc.).&lt;br&gt;
They do this intentionally to reduce spam, prevent abuse, and protect instance IP reputations.&lt;/p&gt;

&lt;p&gt;Unfortunately for me, this meant any attempt to connect via the usual SMTP routes was doomed to fail.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Workaround
&lt;/h2&gt;

&lt;p&gt;Thankfully, my SMTP provider happened to support an alternate port that DigitalOcean didn’t block.&lt;br&gt;
I switched to that port, and emails started flowing again. 🎉&lt;/p&gt;

&lt;p&gt;But this was just a &lt;strong&gt;temporary fix&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Better Approach
&lt;/h2&gt;

&lt;p&gt;Moving forward, I’ve decided to avoid relying on SMTP altogether. Instead, I’ll be using &lt;strong&gt;email provider APIs&lt;/strong&gt; for sending emails. They’re faster, more reliable, and not at the mercy of port restrictions.&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%2Fja7lzgn42tf378xcdup0.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%2Fja7lzgn42tf378xcdup0.png" alt="Using Mailtrap package" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Lesson Learned
&lt;/h2&gt;

&lt;p&gt;What started out looking like a provider issue turned out to be a &lt;strong&gt;hosting environment limitation&lt;/strong&gt;.&lt;br&gt;
It reminded me of a simple but important lesson:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Always question your assumptions before blaming the wrong part of the stack.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And just like that, my brief urge to build a custom SMTP server quietly died. 😀&lt;/p&gt;

</description>
      <category>smtp</category>
      <category>nodemailer</category>
      <category>devops</category>
    </item>
    <item>
      <title>Circular Dependencies in NestJs</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Sun, 15 Jun 2025 21:05:14 +0000</pubDate>
      <link>https://forem.com/codarbind/circular-dependencies-in-nestjs-1fp8</link>
      <guid>https://forem.com/codarbind/circular-dependencies-in-nestjs-1fp8</guid>
      <description>&lt;p&gt;Circular dependency is a situation where two modules depend on one another.&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%2Ffl5vbmg8ulc0djhrlj9r.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%2Ffl5vbmg8ulc0djhrlj9r.png" alt="It is You - It is You" width="560" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One way to resolve this is to make just one of them depend on the other. So A ---&amp;gt; B, and B !----&amp;gt; A 😁&lt;/p&gt;

&lt;p&gt;Another way is to use the forwardRef function provided in NestJs.&lt;/p&gt;

&lt;p&gt;ForwarRef(B) inside A-Module&lt;br&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%2F6oypq81lznacu0zjsdpr.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%2F6oypq81lznacu0zjsdpr.png" alt="From Module A" width="788" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ForwardRef(A) inside B-Module&lt;br&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%2Fs3b01x6s776k84yp64p5.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%2Fs3b01x6s776k84yp64p5.png" alt="From Module B" width="764" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will resolve most circular dependency issues; however, some are stubborn.&lt;/p&gt;

&lt;p&gt;So, you need the silver bullet (🤦‍♂️):&lt;/p&gt;

&lt;p&gt;Specifically Inject() the exceptional service(s)&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%2Frt21d6jcdwgd974wo4yb.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%2Frt21d6jcdwgd974wo4yb.png" alt="Inject the Service with ForwardRef" width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>forwardref</category>
      <category>dependencyinversion</category>
    </item>
    <item>
      <title>'List&lt;Object?&gt;' is not a subtype of type 'PigeonUserDetails?'</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Mon, 23 Sep 2024 04:11:41 +0000</pubDate>
      <link>https://forem.com/codarbind/listobject-is-not-a-subtype-of-type-pigeonuserdetails-4imj</link>
      <guid>https://forem.com/codarbind/listobject-is-not-a-subtype-of-type-pigeonuserdetails-4imj</guid>
      <description>&lt;p&gt;After I rebuilt my project to resolve an issue with a @freezed class my Google login feature started throwing errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'List&amp;lt;Object?&amp;gt;' is not a subtype of type 'PigeonUserDetails?'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I saw the issue on &lt;a href="https://github.com/firebase/flutterfire/issues/13077" rel="noopener noreferrer"&gt;github&lt;/a&gt;, sadly the solution provided there did not work.&lt;/p&gt;

&lt;p&gt;Doing some debugprints helped a bit but I could not see the status of the line that is failing after the last debugprint, hence I opted for the debugger, and then placed some breaking points.&lt;/p&gt;

&lt;p&gt;I realized that there was no &lt;strong&gt;signInWithCredential&lt;/strong&gt; method but there was currentUser which had the details of the logging-in user&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//before
 UserCredential result = await auth.signInWithCredential(authCredential);

//after
 User? result =  auth.currentUser;//signInWithCredential(authCredential);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>firebase</category>
      <category>flutter</category>
      <category>googlecloud</category>
    </item>
    <item>
      <title>SMTP NODEMAILER TOO MANY CONNECTIONS</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Tue, 06 Aug 2024 08:01:17 +0000</pubDate>
      <link>https://forem.com/codarbind/smtp-nodemailer-too-many-connections-2b7a</link>
      <guid>https://forem.com/codarbind/smtp-nodemailer-too-many-connections-2b7a</guid>
      <description>&lt;p&gt;Straight to the point, if you encounter this error while sending emails via nodemailer module then you are likely sending too many mails while creating/using different connections simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3k99bvha9dvga3jlmf3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3k99bvha9dvga3jlmf3o.png" alt="nodemailer error message" width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SOLUTION - &lt;/p&gt;

&lt;p&gt;Configure your transporter to use the pool feature. See how below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7oil463725m4r978xen4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7oil463725m4r978xen4.png" alt="nodemailer pooling config" width="696" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should be fine by now, so let's go verbose.&lt;/p&gt;

&lt;p&gt;When you make a request to a server, a connection is opened to that server. If you do not have other requests at that time, then you may forget abou the opened connection and go your way.&lt;/p&gt;

&lt;p&gt;If you have another request, say instantly, you may also open another connection to that server. Meaning, you can open a different connection for each request that you want to make. Hence, from your authentication, you can have multiple connections opened at the same time - simultaneously.&lt;/p&gt;

&lt;p&gt;It is possible you attempt that, and it is possible that the server limit how much you can open - the limit.&lt;/p&gt;

&lt;p&gt;The question is, why can't we reuse a connection that we have already opened? To save resources. The art of reusing opened connections is POOLING.&lt;/p&gt;

&lt;p&gt;Hence, instead of opening multiple, unnecessary, connections we can just open one, or a few, and reuse them as required.&lt;/p&gt;

&lt;p&gt;Fortunately, &lt;a href="https://nodemailer.com/smtp/pooled/#:~:text=If%20pooling%20is%20used%20then%20Nodemailer%20keeps%20a,only%20use%20a%20small%20amount%20of%20parallel%20connections." rel="noopener noreferrer"&gt;nodemail&lt;/a&gt; supports this.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Vercel: Server Timed Out</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Sun, 21 Jul 2024 15:01:14 +0000</pubDate>
      <link>https://forem.com/codarbind/vercel-server-timed-out-2epb</link>
      <guid>https://forem.com/codarbind/vercel-server-timed-out-2epb</guid>
      <description>&lt;p&gt;Got this screenshot in my DM as the frontend developer on a project,some certain pages are not loading.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgj2k9q7m44lfpvztx98z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgj2k9q7m44lfpvztx98z.jpg" alt="Screenshot of server timed out on Vercel" width="498" height="851"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon investigating I realized that if the page was refreshed it would come up. &lt;/p&gt;

&lt;p&gt;Essentially the affected pages are server-side rendered, and a recent push to the endpoints that serve them is taking so long to run.&lt;/p&gt;

&lt;p&gt;Vercel has limits on running functions, depending on the plan that you're in, the invocation would time out and return the page above.&lt;/p&gt;

&lt;p&gt;The backend needs refactoring, but we needed to mitigate this.&lt;/p&gt;

&lt;p&gt;Vercel has configurations to &lt;a href="https://vercel.com/docs/functions/configuring-functions/duration" rel="noopener noreferrer"&gt;change some defaults&lt;/a&gt;. You can increase the maxDuration timeout depending on the plan that you are&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9qulw65t78isalwaogx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9qulw65t78isalwaogx.png" alt="Ivercel.json config" width="309" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Created/update a &lt;code&gt;vercel.json&lt;/code&gt; file accordingly, perhaps, as seen above.&lt;/p&gt;

&lt;p&gt;We were fine.&lt;/p&gt;

</description>
      <category>vercel</category>
      <category>ssr</category>
      <category>frontend</category>
    </item>
    <item>
      <title>How To Sort Array of Strings</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Fri, 05 Jul 2024 19:07:49 +0000</pubDate>
      <link>https://forem.com/codarbind/how-to-sort-array-of-strings-57m3</link>
      <guid>https://forem.com/codarbind/how-to-sort-array-of-strings-57m3</guid>
      <description>&lt;p&gt;I was building a &lt;a href="https://github.com/codarbind/pdf-merger" rel="noopener noreferrer"&gt;pdf merger&lt;/a&gt; that takes two pdf files, merge them, then return a single file - result of the merging.&lt;/p&gt;

&lt;p&gt;There is a requirement that the files must be in order, i.e. a particular file has to be at the top.&lt;/p&gt;

&lt;p&gt;Since I exposed this via an endpoint, and I am using multer to manage file uploads as shown below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; upload.fields([{ name: 'pdf1', maxCount: 1 }, { name: 'pdf2', maxCount: 1 }])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Multer would not order the files, and there is no guarantee on how what I would get from Multer I had to resort to sorting the array of 'processed files' from multer. I sorted by 'filename.'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;files.sort((a, b) =&amp;gt; a.filename - b.filename);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To my greatest shock, the array was not sorted.&lt;/p&gt;

&lt;p&gt;I hurriedly went to my terminal. launched REPL and tried it, then it got sorted on REPL. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr96y2afjpsilfxh4wdmv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr96y2afjpsilfxh4wdmv.png" alt="repl sorted the array of strings" width="329" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;😲&lt;/p&gt;

&lt;p&gt;How? Why?&lt;/p&gt;

&lt;p&gt;Then I went back to the basics of sorting, comparing, and returning -1, 0, or 1 if the first argument is lesser, equal, or greater than the second argument, respectively.&lt;/p&gt;

&lt;p&gt;Like this -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9wfisw4k7s2i6bwxh8dd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9wfisw4k7s2i6bwxh8dd.png" alt="sorting array of strings with guarantee" width="800" height="652"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you encountered a similar issue before? Or an inconsistency on REPL?&lt;/p&gt;

&lt;p&gt;I would love to hear from you.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>550 5.7.1 Relaying denied</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Tue, 14 May 2024 05:54:11 +0000</pubDate>
      <link>https://forem.com/codarbind/550-571-relaying-denied-3167</link>
      <guid>https://forem.com/codarbind/550-571-relaying-denied-3167</guid>
      <description>&lt;p&gt;Ooops&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fhkbez8ir35iy41ne21b4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fhkbez8ir35iy41ne21b4.png" alt="error message from bounced email"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's the error I got when I tried to send a test mail to a mailbox.&lt;/p&gt;

&lt;p&gt;We observed that external emails were not coming in so we decided to test.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Message not delivered&lt;br&gt;
Your message couldn't be delivered to [redacted] because the remote server is misconfigured. See technical details below for more information.&lt;br&gt;
The response from the remote server was:&lt;br&gt;
550 5.7.1 Relaying denied&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The first thing that came to my mind was the DNS records, I went through them and confirmed that the MXs were good. I recently switched to the present DNS provider. So that is a suspect.&lt;/p&gt;

&lt;p&gt;I researched the &lt;code&gt;550 5.7.1 Relaying denied&lt;/code&gt; and found out that it's truly related to DNS misconfiguration.&lt;/p&gt;

&lt;p&gt;Went through the DNS records again, giving attention to the MXs, and realized that there is Mailgun mx record, we stopped/deactivated our Mailgun accounts a while ago. The suspect is pinned down.&lt;/p&gt;

&lt;p&gt;I then proceeded to delete MX records that pointed to Mailgun, waited for some minutes then retried sending a mail test.&lt;/p&gt;

&lt;p&gt;No more errors, mail well received.&lt;/p&gt;

</description>
      <category>sysadmin</category>
      <category>dns</category>
      <category>email</category>
    </item>
    <item>
      <title>WEB API VULNERABILITY THROUGH OTP</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Wed, 08 May 2024 17:08:53 +0000</pubDate>
      <link>https://forem.com/codarbind/web-api-vulnerability-through-otp-3hk0</link>
      <guid>https://forem.com/codarbind/web-api-vulnerability-through-otp-3hk0</guid>
      <description>&lt;p&gt;Broken Authentication is a popular part of OWASP TOP 10 list.&lt;/p&gt;

&lt;p&gt;Authentication is one of the most important aspects of a platform.&lt;/p&gt;

&lt;p&gt;It is the act of confirming that the user that wants to use the platform now through a particular account is actually the user that owns that account - assuming no user would share their login details.&lt;/p&gt;

&lt;p&gt;The login details are registered into the system at sign up stage, most the details are password and email address.&lt;/p&gt;

&lt;p&gt;Email address is regarded as WHAT YOU HAVE and password is WHAT YOU KNOW. The third factor of authentication is WHO YOU ARE e.g biometric.&lt;/p&gt;

&lt;p&gt;When you put down your email address to sign-up, platforms need to confirm if truly you have that email. One way they confirm is by sending you a mail with a token/code which you are to copy and input into the provided place in the platform. If you are not able to do this then it would be considered that you don't have the email address, and your sign-up would not be complete.&lt;/p&gt;

&lt;p&gt;Also after signing up it is possible for a user to forget their password, locking them out of their accounts. &lt;/p&gt;

&lt;p&gt;Platforms provide means for users to get back their accounts by allowing users to reset their password. This is also achieved by confirming if the user that wants to reset the password actually HAVE (access) to the email box of the corresponding email address on the said account.&lt;/p&gt;

&lt;p&gt;Typical content of such email that's sent looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnkwanu5vst83vys68frv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnkwanu5vst83vys68frv.jpg" alt="screenshot of OTP email " width="800" height="1777"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However going extra mile, hackers can sign-up or reset a password of an account for which they don't have the email address. This is possible especially when the platform is being accessed via web.&lt;/p&gt;

&lt;p&gt;How?&lt;/p&gt;

&lt;p&gt;Most of the codes that are sent are 4 digits. Okay, let's start from here: how many guess would it take to guess a single digit number? 10 guesses. How many would it take to guess two digits? 100. How many guesses would it take to guess four digits 10000.&lt;/p&gt;

&lt;p&gt;Hackers, without having the email address, can just run from 0000 through 9999 and calling the API endpoint for each guess. They'd probably hit luck before reaching 9999. Hence defeating the check of WHAT YOU HAVE.&lt;/p&gt;

&lt;p&gt;How many guesses would they have to make if the digits were 6? 1000000. Yeah that's one million guesses.&lt;/p&gt;

&lt;p&gt;Hence the more the digits the more secure and impractical it becomes for hackers to guess.&lt;/p&gt;

&lt;p&gt;With this the platform would be safer of broken authentication.&lt;/p&gt;

&lt;p&gt;In one of my next articles I will write about whether to send a verification link is better than sending OTP/codes. What do you think?&lt;/p&gt;

</description>
      <category>apisecurity</category>
      <category>webdev</category>
      <category>owasp</category>
    </item>
    <item>
      <title>How would you handle image upload?</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Thu, 21 Mar 2024 12:48:42 +0000</pubDate>
      <link>https://forem.com/codarbind/how-would-you-handle-image-upload-31ep</link>
      <guid>https://forem.com/codarbind/how-would-you-handle-image-upload-31ep</guid>
      <description>&lt;p&gt;User uploads profile picture.&lt;/p&gt;

&lt;p&gt;Images are converted into URLs via third party asset storage.&lt;/p&gt;

&lt;p&gt;Backend handles the conversion.&lt;/p&gt;

&lt;p&gt;Which of the scenarios below would you adopt and why?&lt;/p&gt;

&lt;p&gt;A. Frontend should call convertImageToUrl endpoint, then call updateprofilepicture endpoint with the image url.&lt;/p&gt;

&lt;p&gt;B. Frontend should call updateprofilepicture endpoint with the raw image - so backend handles the conversion to url in that  endpoint implementation.&lt;/p&gt;

&lt;p&gt;What are your reasons?&lt;/p&gt;

</description>
      <category>image</category>
      <category>backenddevelopment</category>
      <category>frontend</category>
      <category>upload</category>
    </item>
    <item>
      <title>How to Automatically Remove Console Logs and Other Code Snippets</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Fri, 03 Nov 2023 02:26:00 +0000</pubDate>
      <link>https://forem.com/codarbind/how-to-automatically-remove-console-logs-and-other-code-snippets-1b02</link>
      <guid>https://forem.com/codarbind/how-to-automatically-remove-console-logs-and-other-code-snippets-1b02</guid>
      <description>&lt;h2&gt;
  
  
  Why Hidis?
&lt;/h2&gt;

&lt;p&gt;Supports ES6 ✅&lt;/p&gt;

&lt;p&gt;Supports JS ✅&lt;/p&gt;

&lt;p&gt;Supports Typescript ❌ - coming soon&lt;/p&gt;

&lt;p&gt;Supports CJS ✅&lt;/p&gt;

&lt;p&gt;Hidis is a tool designed for developers who need to keep certain functions and code snippets on their local machines during development without committing or pushing them to remote branches (e.g., production).&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Hidis Installation:
&lt;/h2&gt;

&lt;p&gt;Hidis relies on pre commit hooks to achieve its goal.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Install Husky:&lt;/strong&gt; Confirm that you have the &lt;code&gt;husky&lt;/code&gt; package installed. If not, you can install it using the following npm command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm  i  husky  &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Setup Husky for Hidis:&lt;/strong&gt; After installing Husky, run the following commands in your terminal, one after the other - &lt;strong&gt;take note of the differences for cjs and es6&lt;/strong&gt;:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;a. &lt;em&gt;General to cjs and es6&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm  pkg  &lt;span class="nb"&gt;set  &lt;/span&gt;scripts.prepare&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"husky install"&lt;/span&gt;

npm  run  prepare
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;b. 🛑🛑🛑&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;If your project type is ES Module i.e you use import/export&lt;/em&gt;, run this 👇:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
npx  husky  add  .husky/pre-commit  &lt;span class="s2"&gt;"node .hidis/precomm.js"&lt;/span&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;If your project type is CJS i.e. you use require(), run this 👇&lt;/em&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx  husky  add  .husky/pre-commit  &lt;span class="s2"&gt;"node .hidis/precomm.c.js"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;c. &lt;em&gt;General to cjs and es6&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git  add  .husky/pre-commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Hidis Installation:
&lt;/h2&gt;

&lt;p&gt;To install Hidis, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm  &lt;span class="nb"&gt;install  &lt;/span&gt;hidis  &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Hidis Setup
&lt;/h3&gt;

&lt;p&gt;Hidis creates a folder named (.hidis) inside your root directory.&lt;/p&gt;

&lt;p&gt;You need to import this folder only once but in your main /entry point file and &lt;strong&gt;in the first line.&lt;/strong&gt; If not imported at first line then you will get Reference error, it is like you want to use hidis before its birth. 😆&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ReferenceError: hidis is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import &lt;code&gt;hidis&lt;/code&gt; like the below inside a file that you are sure would be loaded/required when the node server starts. It is called &lt;code&gt;main entry point file&lt;/code&gt;. Your main file could be app.js or index.js. To confirm which file, check your &lt;code&gt;package.json&lt;/code&gt; look for the value of main, that value/path leads to the file you are looking for.&lt;/p&gt;

&lt;p&gt;Also ensure that the path you provides (import from) correctly points to the &lt;code&gt;.hidis/index.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;For projects in ES6 *&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./.hidis/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;For projects in Cjs *&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./.hidis/index.c.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How does it work?
&lt;/h2&gt;

&lt;p&gt;To use Hidis, start your Nodejs server, call the &lt;code&gt;hidis&lt;/code&gt; function anywhere in your project. Hidis takes a string as an argument. Make sure to separate more than one line of code with semicolons. Here's a sample:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;hidis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;console.log("Everything inside this hidis would not be committed"); let name = "suliyat"; console.log(`My name is not ${name}`)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run &lt;code&gt;git commit -m {your commit message}&lt;/code&gt; Hidis would hide &lt;code&gt;hidis&lt;/code&gt; functions and their arguments from being committed, thus from being pushed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ghost Mode - Original Content
&lt;/h2&gt;

&lt;p&gt;Sometimes you still need the &lt;code&gt;hidis&lt;/code&gt; functions on your local machine after committing/pushing, so permanently deleting &lt;code&gt;hidis&lt;/code&gt; functions at every commit might not present a good dev experience (DX).&lt;/p&gt;

&lt;p&gt;To ensure good DX you have the option to choose if you want the &lt;code&gt;hidis&lt;/code&gt; functions permanently removed or not. Run the following command to change the config. the &lt;code&gt;default&lt;/code&gt; is true (i.e. returns &lt;code&gt;hidis&lt;/code&gt; functions back into their places)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm  run  hidisConfig  &lt;span class="nt"&gt;--&lt;/span&gt;  original &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt; |  &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In ghost mode committed files would still appear 'unstaged', as if they have not been committed but they have been! It is just ghosting . . . 😁&lt;/p&gt;

&lt;h2&gt;
  
  
  Errors
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Error: provide arguments: to resolve this error ensure the &lt;code&gt;hidisConfig&lt;/code&gt; property in your package.json script is set appropriately - only one command should be there, just like in the sample below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For this sample, the project is a cjs project - uses require().&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"echo &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Error: no test specified&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &amp;amp;&amp;amp; exit 1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"nodemon index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"prepare"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"husky install"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"hidisConfig"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node .hidis/config.c.js"&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tweet at me &lt;a href="https://twitter.com/wahabind"&gt;https://twitter.com/wahabind&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Always Return an Object - Why?</title>
      <dc:creator>ADEKOLA Abdwahab</dc:creator>
      <pubDate>Sat, 03 Jun 2023 11:49:00 +0000</pubDate>
      <link>https://forem.com/codarbind/always-return-an-object-why-3f8i</link>
      <guid>https://forem.com/codarbind/always-return-an-object-why-3f8i</guid>
      <description>&lt;p&gt;Look at this function:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function canShare(username){&lt;br&gt;
....&lt;br&gt;
Do some checks &lt;br&gt;
...&lt;br&gt;
return true&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Code snippet 1&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When we call canShare('uyut') we get true or false. There's no problem with this.&lt;/p&gt;

&lt;p&gt;So you could call/use the function like this:&lt;/p&gt;

&lt;p&gt;`if (!canShare) {&lt;br&gt;
Do something else&lt;/p&gt;

&lt;p&gt;alert('cannot share')&lt;br&gt;
}`&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;code snippet 2&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However when building API services, especially one consumed by third parties this kind of return could be a pain when the API grows.&lt;/p&gt;

&lt;p&gt;With the snippet above the user only know they can't, there's no provision to let them know why they cannot or what action they need to take to resolve it.&lt;/p&gt;

&lt;p&gt;To achieve this the function needs to return more than a Boolean but what...an object!&lt;/p&gt;

&lt;p&gt;However with the initial type of return, couple of things would have to be changed to accommodate the change - and there'd be ripple effects.&lt;/p&gt;

&lt;p&gt;We can edit the function to return an object of this structure:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function canShare(username){&lt;br&gt;
...&lt;br&gt;
return {success:Boolean, message: string, action: string}&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Code snippet 3&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If an object is now returned the code snippet 2 would have to change to&lt;/p&gt;

&lt;p&gt;`if (!canShare.success) {&lt;br&gt;
Do something else&lt;/p&gt;

&lt;p&gt;alert('cannot share')&lt;br&gt;
}`&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Code snippet 4&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This looks like a simple change, however imagine the function being used in multiple ways, in multiple places.&lt;/p&gt;

&lt;p&gt;What do you think?&lt;/p&gt;

&lt;p&gt;Are there instances you think returning object would not fit?&lt;/p&gt;

&lt;p&gt;What's your experience with issues like this?&lt;/p&gt;

&lt;p&gt;Share, I want to read from you!&lt;/p&gt;

</description>
      <category>api</category>
      <category>response</category>
      <category>javascript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
