A high-performance Node.js REST API for tracking country statistics, backed by Redis.
- 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.
- Node.js (v18+)
- Docker & Docker Compose
-
Install Dependencies
npm install
-
Start Redis
docker compose up -d
Note: Redis will run on port 6380 to avoid conflicts with default local instances.
-
Run the Server
npm start
The server will start on
http://localhost:3000.
POST /api/track
Payload:
{
"country": "US"
}Response:
{
"success": true
}GET /api/stats
Response:
{
"US": 105,
"FR": 80
}Ensure Redis is running (via Docker), then run:
npm test