A Node.js command-line interface app for converting currencies.
To run this tool, you must obtain a key from Open Exchange Rates. This is easy and doesn't require that you give credit card info.
Users are able to select both the input and output currency type. Conversion records are stored in a local Mongo database. Besides doing simple conversions, the user can retrieve the last conversion, up to 10 of the most recent conversions, and can choose a convert-to currency to filter on. Finally, the entire db can be exported to a .csv file. The user can choose and file name and file location, though the path defaults to the current directory so if the user doesn't want to enter a file path, they do not need to.
- Node.JS
- I've been running v8.11.2 during development and manual testing
- MongoDB
- The database needs to be running. For more info on installing and setting up MongoDB, visit Install MongoDB Community Edition.
- I've been running MongoDB shell version v3.6.5 during development and manual testing
- git (needed if cloning this repo)
For details, see the package.json file.
- Command line interface is supported by the
commanderandinquirerpackages - API access depends on the
requestanddotenvpackages - Conversion record validation and storage depends on
mongoose - CSV export uses the
json2csvpackage and Node's core File System modules - Multiple formatting packages were used to improve terminal output readability (
columnify,currency-symbol-map,moment, andpluralize)
- Clone the currency converter repo and move into the currency_converter directory.
git clone https://github.com/gingin77/currency_converter.git
cd currency_converter- To access the executable
currycommand, you'll need to run a global npm install, which may or may not require you to usesudo:
currency_converter $ sudo npm i -g-
You should now be able to run
curry --helpto see a list of options. -
Using a browser, sign up for a free account at openexchangerates.org and obtain an API key.
-
Copy the .env.sample to a new .env file
cp .env.sample .env- Open your
.envfile and replace the dummy string with the API key obtained from Open Exchange Rates.
# .env
OPEN_EXCHANGE_KEY = 235233_your_actual_key_goes_here_53531513346713476currency_converter $ curry --help
Usage: curry [options] [command]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
convert Prompts user to submit currency types and a value to convert
last-one Retrieves a record of the last conversion
last-ten Retrieves up to 10 of the most recent conversions
query-currency Returns up to 10 records for a selected converted-to currency
csv-export Allows ALL historical conversions to be exported to a .csv file- If you see
nullafterGetting exchange rates....as shown in the example below, you are not connecting with the Open Exchange Rates API and likely need to add your key to the .env file.
currency_converter $ curry convert
? Choose a base currency type to convert from: United States Dollar
? Choose a currency type to convert to: Brazilian Real
? How much do you want to convert? 78900
Getting exchange rates...
null- Error handling is incomplete, so use control+C to return to the terminal prompt when the script hangs.





