<?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: Enoch Philip Dibal</title>
    <description>The latest articles on Forem by Enoch Philip Dibal (@enoch_philipdibal_cb323b).</description>
    <link>https://forem.com/enoch_philipdibal_cb323b</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%2F2498236%2Fea14176e-8b65-440d-9dc1-0f21fb79a7a1.jpg</url>
      <title>Forem: Enoch Philip Dibal</title>
      <link>https://forem.com/enoch_philipdibal_cb323b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/enoch_philipdibal_cb323b"/>
    <language>en</language>
    <item>
      <title>Building a Dynamic Profile Endpoint with Express.js</title>
      <dc:creator>Enoch Philip Dibal</dc:creator>
      <pubDate>Fri, 17 Oct 2025 09:59:54 +0000</pubDate>
      <link>https://forem.com/enoch_philipdibal_cb323b/building-a-dynamic-profile-endpoint-with-expressjs-37ga</link>
      <guid>https://forem.com/enoch_philipdibal_cb323b/building-a-dynamic-profile-endpoint-with-expressjs-37ga</guid>
      <description>&lt;p&gt;I recently completed Stage 0 of the Backend Wizards challenge. The task was to build a RESTful API endpoint that returns my profile information along with a dynamic cat fact from the Cat Facts API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a GET /me endpoint&lt;/li&gt;
&lt;li&gt;Return JSON with my profile, current UTC timestamp, and a dynamic cat fact&lt;/li&gt;
&lt;li&gt;Handle errors gracefully&lt;/li&gt;
&lt;li&gt;Ensure proper formatting for automated grading&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%2Fvauidy2f0rfpkm5p3l9x.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%2Fvauidy2f0rfpkm5p3l9x.png" alt=" " width="567" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Set up Express.js&lt;/strong&gt;: Installed express, axios, cors, and morgan for request logging.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Profile object&lt;/strong&gt;: Stored email, full name, and stack as a constant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic cat fact&lt;/strong&gt;: Fetched from Cat Facts API using Axios with a 5-second timeout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error handling&lt;/strong&gt;: Added fallback in case the API fails.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timestamps&lt;/strong&gt;: Generated ISO 8601 UTC timestamps dynamically on each request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CORS and logging&lt;/strong&gt;: Enabled CORS for public access, used Morgan for request logs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deployment-ready&lt;/strong&gt;: Prepared for Railway with a proper start script.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Learnings:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to integrate third-party APIs in real-time&lt;/li&gt;
&lt;li&gt;Handling API failures gracefully&lt;/li&gt;
&lt;li&gt;Returning strictly formatted JSON for automated grading&lt;/li&gt;
&lt;li&gt;Setting up a simple, production-ready Express server&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "status": "success",
  "user": {
    "email": "your.email@example.com",
    "name": "Your Full Name",
    "stack": "Node.js/Express"
  },
  "timestamp": "2025-10-17T14:25:36.123Z",
  "fact": "Cats have five toes on their front paws, but only four toes on their back paws."
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Snapshots / Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local test&lt;/strong&gt;: &lt;a href="http://localhost:3000/me" rel="noopener noreferrer"&gt;http://localhost:3000/me&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Heroku deployed test&lt;/strong&gt;: &lt;a href="https://hng-internship-enoch-stage0-970ab657030f.herokuapp.com/me" rel="noopener noreferrer"&gt;https://hng-internship-enoch-stage0-970ab657030f.herokuapp.com/me&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stage 1 will expand the backend with database integration and more dynamic endpoints.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This task taught me the importance of combining clean code, proper error handling, and dynamic API consumption while keeping responses predictable and automated-test friendly.&lt;/p&gt;

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