<?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: Frank Micheal</title>
    <description>The latest articles on DEV Community by Frank Micheal (@trayshmhirk).</description>
    <link>https://dev.to/trayshmhirk</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%2F3570913%2Fc6c4fda9-b62f-442c-825e-7eb8f4c703ea.jpeg</url>
      <title>DEV Community: Frank Micheal</title>
      <link>https://dev.to/trayshmhirk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/trayshmhirk"/>
    <language>en</language>
    <item>
      <title>HNG 13 Backend Stage 0 – Building a Simple API with Node.js and Express</title>
      <dc:creator>Frank Micheal</dc:creator>
      <pubDate>Fri, 17 Oct 2025 11:43:40 +0000</pubDate>
      <link>https://dev.to/trayshmhirk/hng-13-backend-stage-0-building-a-simple-api-with-nodejs-and-express-3k55</link>
      <guid>https://dev.to/trayshmhirk/hng-13-backend-stage-0-building-a-simple-api-with-nodejs-and-express-3k55</guid>
      <description>&lt;h1&gt;
  
  
  🚀 Backend Stage 0: Building a Dynamic Profile API with Node.js &amp;amp; Express
&lt;/h1&gt;

&lt;p&gt;Hey everyone 👋, I'm &lt;strong&gt;Trayshmhirk&lt;/strong&gt;, and this is my submission for the &lt;strong&gt;HNG 13 Backend Stage 0 Task&lt;/strong&gt; — where we were asked to build a simple RESTful API endpoint that returns our profile information along with a dynamic cat fact fetched from the &lt;a href="https://catfact.ninja/fact" rel="noopener noreferrer"&gt;Cat Facts API&lt;/a&gt;. 🐱&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Task Overview
&lt;/h2&gt;

&lt;p&gt;The goal was to create a &lt;strong&gt;GET /me&lt;/strong&gt; endpoint that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Returns a JSON response containing:

&lt;ul&gt;
&lt;li&gt;My name, email, and backend stack&lt;/li&gt;
&lt;li&gt;A timestamp (in ISO 8601 format)&lt;/li&gt;
&lt;li&gt;A random cat fact fetched from an external API&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Uses best practices for clean, maintainable backend code&lt;/li&gt;

&lt;li&gt;Handles API errors gracefully&lt;/li&gt;

&lt;li&gt;Is hosted online (I used &lt;strong&gt;Railway&lt;/strong&gt; 🚉)&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚙️ Tech Stack
&lt;/h2&gt;

&lt;p&gt;For this task, I used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js&lt;/strong&gt; – JavaScript runtime environment&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Express.js&lt;/strong&gt; – Web framework for building APIs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Axios&lt;/strong&gt; – To fetch data from the Cat Facts API&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CORS&lt;/strong&gt; – To allow external access to the endpoint&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🏗️ How I Built It
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Project setup&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
   npm &lt;span class="nb"&gt;install &lt;/span&gt;express axios cors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Created folder structure&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   src/
   ├── app.js              &lt;span class="c"&gt;# Express setup&lt;/span&gt;
   ├── routes/
   │   └── profile.js      &lt;span class="c"&gt;# /me route logic&lt;/span&gt;
   └── services/
       └── cat-facts.js    &lt;span class="c"&gt;# External API integration&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integrated the Cat Facts API&lt;/strong&gt; &lt;br&gt;
I used Axios to fetch a random fact from the endpoint &lt;code&gt;https://catfact.ninja/fact&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
If the request fails (e.g., timeout or API down), I return a friendly fallback message like:&lt;br&gt;&lt;br&gt;
&lt;code&gt;"Could not fetch cat fact at the moment."&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Built the &lt;code&gt;/me&lt;/code&gt; route&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The route responds with this structure:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&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;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"user"&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;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"harlex.mikkey@gmail.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Micheal Osunbajo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"stack"&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.js/Express"&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;"timestamp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2025-10-17T14:23:45.678Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"fact"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Cats have over 20 vocalizations, including the purr, meow, and chirp."&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Deployment on Railway&lt;/strong&gt;
I deployed the API to &lt;a href="https://railway.app" rel="noopener noreferrer"&gt;Railway&lt;/a&gt;, which automatically detects Node.js projects and assigns a public URL.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Live Endpoint:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
   🔗 &lt;a href="https://tray-stage-zero-backend-task-production.up.railway.app/me" rel="noopener noreferrer"&gt;https://tray-stage-zero-backend-task-production.up.railway.app/me&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 What I Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to build and structure a simple Express.js API from scratch&lt;/li&gt;
&lt;li&gt;How to make and handle external API requests using Axios&lt;/li&gt;
&lt;li&gt;How to properly return JSON responses in RESTful APIs&lt;/li&gt;
&lt;li&gt;How to deploy a Node.js app to Railway&lt;/li&gt;
&lt;li&gt;The importance of clear README documentation and error handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This task was a great refresher on backend fundamentals and a perfect warm-up for the upcoming stages. 🔥&lt;/p&gt;




&lt;h2&gt;
  
  
  🧾 GitHub Repository
&lt;/h2&gt;

&lt;p&gt;📂 &lt;strong&gt;Repository:&lt;/strong&gt; &lt;a href="https://github.com/Trayshmhirk/tray-stage-zero-backend-task.git" rel="noopener noreferrer"&gt;https://github.com/Trayshmhirk/tray-stage-zero-backend-task.git&lt;/a&gt;&lt;/p&gt;




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

&lt;p&gt;Even though the task was small, I treated it like a real-world microservice — clean folder structure, graceful error handling, and proper documentation.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Start small, but build like a pro."&lt;/em&gt; 💪&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;Author:&lt;/strong&gt; Micheal Osunbajo&lt;br&gt;&lt;br&gt;
📧 &lt;a href="//mailto:harlex.mikkey@gmail.com"&gt;harlex.mikkey@gmail.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;
💻 Stack: Node.js / Express&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cat facts provided by &lt;a href="https://catfact.ninja/" rel="noopener noreferrer"&gt;Cat Facts API&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>hng</category>
      <category>javascript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
