Skip to content

gingin77/currency_converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

curry_conv

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.

System Requirements

  1. Node.JS
    • I've been running v8.11.2 during development and manual testing
  2. 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
  3. git (needed if cloning this repo)

Dependencies

For details, see the package.json file.

  • Command line interface is supported by the commander and inquirer packages
  • API access depends on the request and dotenv packages
  • Conversion record validation and storage depends on mongoose
  • CSV export uses the json2csv package and Node's core File System modules
  • Multiple formatting packages were used to improve terminal output readability (columnify, currency-symbol-map, moment, and pluralize)

Installation Steps

  1. Clone the currency converter repo and move into the currency_converter directory.
git clone https://github.com/gingin77/currency_converter.git
cd currency_converter
  1. To access the executable curry command, you'll need to run a global npm install, which may or may not require you to use sudo:
currency_converter $ sudo npm i -g
  1. You should now be able to run curry --help to see a list of options.

  2. Using a browser, sign up for a free account at openexchangerates.org and obtain an API key.

  3. Copy the .env.sample to a new .env file

cp .env.sample .env
  1. Open your .env file and replace the dummy string with the API key obtained from Open Exchange Rates.
# .env
OPEN_EXCHANGE_KEY = 235233_your_actual_key_goes_here_53531513346713476

Options

currency_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

Example Outputs

For curry convert

alt text

For curry last-one

alt text

For curry last-ten

alt text

For curry query-currency

alt text

For curry csv-export: invalid input prompt

alt text

For curry csv-export: success

alt text

Troubleshooting

  • If you see null after Getting 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.

About

A simple currency conversion tool that runs in the terminal - Node.JS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors