This NestJS backend application serves as an API aggregator for country information. It fetches and combines data from two external APIs:
- Nager.Date API for country lists and basic information
- Countries Now API for population data and flag images
- NestJS
- TypeScript
- Axios for HTTP requests
- ConfigModule for environment management
- Node.js (v18.x or later)
- npm (v9.x or later)
- Clone the repository
git clone https://github.com/phpfc/country-info-backend.git
cd country-info-backend
- Install dependencies
npm install
Create a .env
file in the project root with the following variables:
# External API Base URLs
DATE_NAGER_API_URL=https://date.nager.at/api/v3
COUNTRIES_NOW_API_URL=https://countriesnow.space/api/v0.1
# Optional: Custom port (default is 3001)
PORT=3001
npm run start:dev
npm run build
npm run start:prod
The server will run on http://localhost:3001
by default.
- GET
/countries
- Retrieves a list of countries with basic information
- Includes country code, name, and flag URL
- GET
/countries/:code
- Retrieves detailed information for a specific country
- Includes:
- Country name and code
- Population data over time
- Bordering countries with their flags
- Country List API: Nager.Date Swagger
- Country Details API: Countries Now API
src/
countries/
: Core country-related moduleshttp.service.ts
: Centralized HTTP client for external API callsinterfaces/
: TypeScript interfaces for type safety
The backend is configured to allow requests from the frontend application running on http://localhost:3000
.