A basic application to get information about countries via a RESTful API (Node.JS Version).
This version of the API provide a little more information on countries: Flags + a numerous of test. It is the base of the book I am currently writing about testing an API. I have also added few routes and documentation with Apidoc
The original code was named restcountrie. The project is available on the github account of Hengki Sihombin
The original and complete project is available at REST Countries
If Homebrew, Node are not installed. Here the shortest procedure to install all requirements on a Mac. Very brief but you got the essentials, if you have already installed these tools, you can jump to the point 1.
Install Homebrew
Check the website brew.sh or launch in the console the following command.
$ /usr/bin/ruby -e "$(curl -k -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Node and NPM
$ brew update
$ brew doctor
$ export PATH="/usr/local/bin:$PATH"
$ brew install node
Source: https://changelog.com/posts/install-node-js-with-homebrew-on-os-x
You have to install Postman client and possibly Newman. "Newman is a line runner collection for Postman". Postman exists for Mac and for Windows.
- Postman - For the tests' execution, indispensable.
Other possible tools that maybe useful:
- JSONlint - For JSON validation
- JSONschema.net - For the generation of JSON schema
- JSON pathfinder - To make it easier to select data in a JSON (Chrome extension only)
If you already have NPM install and known how to clone
$ cd /path-to-your-where-you-want-to-create-your-app/
$ git clone https://github.com/bflaven/FlagApi.git FlagApi-v2
$ cd FlagApi-v2
$ npm install
$ npm start
Do not forget to launch the API before. The tests are using resources in JSON available in the directory /resources-test/
$ cd /path-to-your-where-you-want-to-create-your-app/FlagApi-v2/
$ npm test
http://localhost:3000/api/v2/
http://localhost:3000/api/v2/region/:region_name
example: http://localhost:3000/api/v2/region/asia
http://localhost:3000/api/v2/subregion/:subregion_name
example: http://localhost:3000/api/v2/subregion/Southern Europe
http://localhost:3000/api/v2/currency/:current_code
example: http://localhost:3000/api/v2/currency/IDR
http://localhost:3000/api/v2/callingcode/:calling_code
example: http://localhost:3000/api/v2/callingcode/60
http://localhost:3000/api/v2/flag/:flag_label
example: http://localhost:3000/api/v2/flag/jp
http://localhost:3000/api/v2/capital/:capital_label
example: http://localhost:3000/api/v2/capital/Santiago
http://localhost:3000/api/v2/language/:nativelanguage_label
example: http://localhost:3000/api/v2/language/spa
http://localhost:3000/api/v2/tld/:tld_label
example: http://localhost:3000/api/v2/tld/.br
http://localhost:3000/api/v2/area/:area_nb