🐱 Building a Minimal /me Endpoint with Pure Node.js (No Frameworks) – HNG Internship Stage 0



This content originally appeared on DEV Community and was authored by tunde

As part of the HNG Internship Stage 0 backend task, I was asked to build a simple REST API that returns my profile information along with a dynamic cat fact from an external API.

Rather than using Express or any framework, I decided to go bare-metal β€” using just Node.js’ built-in http module.

This was a fun challenge that made me revisit the basics of how servers, routes, and responses actually work under the hood.

The goal was to create a GET endpoint at /me that returns a JSON response like this:

{
  "status": "success",
  "user": {
    "email": "your@email.com",
    "name": "Your Full Name",
    "stack": "Node.js/Express"
  },
  "timestamp": "current UTC time in ISO 8601 format",
  "fact": "random cat fact from Cat Facts API"
}

Dynamic data for the “fact” field comes from the Cat Facts API

🛠 Technologies Used

Just the essentials:

🟢 Node.js

💻 Built-in HTTP module

🌐 Native Fetch API (available in Node 18+)

No Express, no frameworks, no extra dependencies, just JavaScript.

🧩 How It Works

1.The server listens for all incoming HTTP requests.

2.If the route matches /me, it:

  • Fetches a random cat fact from https://catfact.ninja/fact
  • Builds a structured JSON object containing my profile and the fact
  • Sends it back with Content-Type: application/json

3.If anything goes wrong (like network errors), it falls back to a default cat fact.

4.Any other route returns a 404 Not Found.

🧪 Live Demo

🌍 Live API:
https://hng13-be-stage-0-production.up.railway.app/me

🧾 GitHub Repository:
https://github.com/tundealabi/hng13-be-stage-0

/me endpoint response


This content originally appeared on DEV Community and was authored by tunde