Skip to content

eliau2005/Country_ID

Repository files navigation

Country ID Tracker API

A high-performance Node.js REST API for tracking country statistics, backed by Redis.

Features

  • High Performance: Built with Fastify and Redis to handle 1,000+ RPS.
  • Atomic Operations: Accurate counting using Redis atomic increments.
  • Dockerized: Easy setup with Docker Compose.

Prerequisites

  • Node.js (v18+)
  • Docker & Docker Compose

Getting Started

  1. Install Dependencies

    npm install
  2. Start Redis

    docker compose up -d

    Note: Redis will run on port 6380 to avoid conflicts with default local instances.

  3. Run the Server

    npm start

    The server will start on http://localhost:3000.

API Endpoints

Track Country

POST /api/track

Payload:

{
  "country": "US"
}

Response:

{
  "success": true
}

Get Statistics

GET /api/stats

Response:

{
  "US": 105,
  "FR": 80
}

Running Tests

Ensure Redis is running (via Docker), then run:

npm test

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors