Hey everyone 👋, I’m Trayshmhirk, and this is my submission for the HNG 13 Backend Stage 0 Task — 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 Cat Facts API. 🐱
🧩 Task Overview
The goal was to create a GET /me endpoint that:
- Returns a JSON response containing:
- My name, email, and backend stack
- A timestamp (in ISO 8601 format)
- A random cat fact fetched from an external API
- Uses best practices for clean, maintainable backend code
- Handles API errors gracefully
- Is hosted online (I used Railway 🚉)
⚙️ Tech Stack
For this task, I used:
- Node.js – JavaScript runtime environment
- Express.js – Web framework for building APIs
- Axios – To fetch data from the Cat Facts API
- CORS – To allow external access to the endpoint
🏗️ How I Built It
- Project setup
npm init -y
npm install express axios cors
- Created folder structure
src/
├── app.js # Express setup
├── routes/
│ └── profile.js # /me route logic
└── services/
└── cat-facts.js # External API integration
-
Integrated the Cat Facts API
I used Axios to fetch a random fact from the endpointhttps://catfact.ninja/fact
.If the request fails (e.g., timeout or API down), I return a friendly fallback message like:
"Could not fetch cat fact at the moment."
-
Built the
/me
routeThe route responds with this structure:
{
"status": "success",
"user": {
"email": "harlex.mikkey@gmail.com",
"name": "Micheal Osunbajo",
"stack": "Node.js/Express"
},
"timestamp": "2025-10-17T14:23:45.678Z",
"fact": "Cats have over 20 vocalizations, including the purr, meow, and chirp."
}
-
Deployment on Railway
I deployed the API to Railway, which automatically detects Node.js projects and assigns a public URL.
Live Endpoint:
🔗 https://tray-stage-zero-backend-task-production.up.railway.app/me
🧠 What I Learned
- How to build and structure a simple Express.js API from scratch
- How to make and handle external API requests using Axios
- How to properly return JSON responses in RESTful APIs
- How to deploy a Node.js app to Railway
- The importance of clear README documentation and error handling
This task was a great refresher on backend fundamentals and a perfect warm-up for the upcoming stages. 🔥
🧾 GitHub Repository
📂 Repository: https://github.com/Trayshmhirk/tray-stage-zero-backend-task.git
🏁 Final Thoughts
Even though the task was small, I treated it like a real-world microservice — clean folder structure, graceful error handling, and proper documentation.
“Start small, but build like a pro.” 💪
Author: Micheal Osunbajo
💻 Stack: Node.js / Express
Cat facts provided by Cat Facts API