I'm excited to share my latest project as part of the HNG Internship Stage Zero task! I built a simple yet functional REST API endpoint that serves dynamic content. This project helped me apply my backend development skills using Node.js and Express.
π Project Overview
I created a /me
endpoint that returns:
- My personal information
- Current UTC timestamp
- A random cat fact that changes with each request
Here's what the response looks like:
{
"status": "success",
"user": {
"email": "emmanueludodirim4@gmail.com",
"name": "Emmanuel Udodirim",
"stack": "Node.js/Express"
},
"timestamp": "2025-10-17T07:37:07Z",
"fact": "Cats have 32 muscles in each ear."
}
π» Tech Stack & Implementation
For this project, I used:
- Node.js/Express: For creating the RESTful API
- Axios: For fetching external data from Cat Facts API
- Railway: For deployment and hosting
The implementation involved:
const express = require('express');
const axios = require('axios');
const app = express();
// GET /me endpoint
app.get('/me', async (req, res) => {
try {
// Fetch cat fact from external API
const catFactResponse = await axios.get('https://catfact.ninja/fact', {
timeout: 5000 // 5 second timeout
});
// Create response object
const response = {
status: 'success',
user: {
email: process.env.USER_EMAIL || 'emmanueludodirim4@gmail.com',
name: process.env.USER_NAME || 'Emmanuel Udodirim',
stack: process.env.USER_STACK || 'Node.js/Express'
},
timestamp: new Date().toISOString(), // Current UTC time in ISO 8601
fact: catFactResponse.data.fact
};
res.status(200).json(response);
} catch (error) {
// Error handling
}
});
π Challenges & Learnings
During this project, I encountered several challenges:
- Deployment Issues: Navigating Railway's configuration requirements
- Port Configuration: Ensuring my app listened on the correct port
π― The Result
The final API is live at: https://hng-stage-zero-backend-production-1abf.up.railway.app/me
You can view the code on GitHub: https://github.com/emmytronix/hng-stage-zero-backend.git
Top comments (1)
Amazing ππ»