https://github.com/eldsonc/backend-country
Backend CountrySearch
https://github.com/eldsonc/backend-country
axios cors dotenv express nodejs typescript
Last synced: 11 months ago
JSON representation
Backend CountrySearch
- Host: GitHub
- URL: https://github.com/eldsonc/backend-country
- Owner: EldsonC
- Created: 2024-09-14T06:27:36.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-14T06:42:00.000Z (almost 2 years ago)
- Last Synced: 2024-10-17T02:04:54.861Z (over 1 year ago)
- Topics: axios, cors, dotenv, express, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 6.54 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Country Information API
## Description
This backend API allows you to fetch information about countries, including:
- All available countries.
- Specific information about a country, including borders, population, and flag.
The API integrates with external services to gather data.
## Technologies Used
- **Languages**: TypeScript
- **Frameworks/Libraries**: Express, Axios
- **Other Tools**: CORS, dotenv
## Installation
### Prerequisites
- **Node.js**
- **Yarn** or **npm**
### Installation Steps
1. Clone the repository:
```bash
git clone https://github.com/EldsonC/backend-country.git
```
2. Navigate into the project directory:
```bash
cd backend-country
```
3. Install the dependencies:
```bash
yarn install
# or
npm install
```
4. Create the `.env` file with the following variables:
```bash
ALL_COUNTRIES_URL="https://date.nager.at/api/v3/AvailableCountries"
COUNTRY_INFO_URL="https://date.nager.at/api/v3/CountryInfo/"
POPULATION_URL="https://countriesnow.space/api/v0.1/countries/population"
FLAGS_URL="https://countriesnow.space/api/v0.1/countries/flag/images"
PORT=3000
```
5. Start the project:
```bash
yarn dev
# or
npm run dev
```
## API Endpoints
### Get All Countries
**GET** `/countries`
Returns a list of all available countries.
#### Response Example:
```json
[
{
"commonName": "United States",
"officialName": "United States of America"
},
{
"commonName": "Brazil",
"officialName": "Federative Republic of Brazil"
}
]