The Country Management System is a web application that provides information about different countries. It allows users to retrieve details about a specific country, and filter and sort a list of countries based on various criteria.
- IntelliJ IDEA
- Maven
- Java
- Postman
-
Clone this repository in IntelliJ:
- copy the link given in the code of this repository.
- paste it into Project with version control.
- Clone it.
-
In Postman, authenticate using cURL by hitting the authentication endpoint:
http://localhost:8080/auth/login
and method: 'POST'.curl --location 'http://localhost:8080/auth/login' \ --header 'Content-Type: application/json' \ --data '{ "username":"User", "password":"Pass123" }'
or
curl --location 'http://localhost:8080/auth/login' \ --header 'Content-Type: application/json' \ --data '{ "username":"Anam", "password":"Anam123" }'
-
Copy the JWT token received in the response.
-
In Postman, add the token to the header:
- Key:
Authorization
- Value:
Bearer your_copied_token
- Key:
-
Please be aware that the token will expire after 5 hours. You may need to re-authenticate and obtain a new token when the current token expires.
- Get Country Information by name with the endpoint:
http://localhost:8080/country/getInfo/country_name/{countryName}
.
curl --location 'http://localhost:8080/country/getInfo/country_name/eesti' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBbmFtIiwiaWF0IjoxNzAzNTc1MTE2LCJleHAiOjE3MDM1OTMxMTZ9.xlm8TRyETVRnD5seeCbtlJuxtIpxmRd-U2bcwp3L1_GweohDiGsK3pP56BGNV5for0-7uSu9EyE96yJcBo3yoQ'
- Get a List of Country Names Based on the Filter and Sort with the endpoint:
http://localhost:8080/country/getCountries?language={language}&population={minPopulation}&area={minArea}&sort={asc/desc}&page={pageNo}&pageSize={pageSize}
curl --location 'http://localhost:8080/country/getCountries?language=spanish&population=1000&area=500.0&sort=desc&page=1&pageSize=10' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJVc2VyIiwiaWF0IjoxNzAzNDk4MzU4LCJleHAiOjE3MDM1MTYzNTh9.lhbI9BkU866EHbiDSIJeq9kTnZ2PzXwSf_N3M3gHMdwxsTf1ypyuFDknyQ3WJjFfOeON4vD4ux62sq7EaV0Zzw'