π― The Challenge
As part of my backend development stage at HNG, I recently built a simple RESTful API that combines personal profile information with dynamic cat facts. Here's my story of turning requirements into a fully deployed application.
π Task Requirements
The goal was straightforward but comprehensive:
- Create a GET endpoint at
/me
- Return JSON with specific structure
- Integrate with external Cat Facts API
- Include dynamic UTC timestamp
- Handle errors gracefully
- Deploy to a cloud platform
π οΈ Tech Stack
- Backend: Node.js with Express
- HTTP Client: Axios for external API calls
- Deployment: Render.com
- Environment Management: dotenv
π The Implementation Journey
Step 1: Setting Up the Foundation
I started by creating a basic Express server with proper middleware:
Step 2: External API Integration
The most exciting part was integrating with the Cat Facts API:
Step 3: Building the Main Endpoint
The core GET /me
endpoint brought everything together:
Challenges
Challenge 1: CORS Package Compatibility
Issue: Path-to-regexp errors with Node.js v22
Solution: Implemented manual CORS headers instead of using the cors package
Challenge 2: Deployment Platform Issues
Experience: Tried PXXL.app initially, encountered "no available server" errors
Solution: Successfully deployed on Render.com with their generous free tier
π The Final Result
API Response Structure
π Project Links
- Main API: https://profile-api-6tan.onrender.com/me
- Health Check: https://profile-api-6tan.onrender.com/health
- GitHub Repository: https://github.com/Ladii1/profile-api.git
π Resources That Helped
Building this API taught me that even simple projects involve complex considerations. From handling time zones to managing external API dependencies, every line of code serves a purpose.
P.S. Don't forget to test the live API and let me know what cat fact you get!
Top comments (0)