This project is a dive into learning more node and serve as a backend to these applications: tipCalc and tipCalcNative
If you want to know more about the app and the frontend then please check out the repos or the design files in Figma
You can find the native version on Google Play!
To get going with the project locally then clone the repo and install all dependencies
npm install
The project uses mongodb. To get up and running do the following:
Install MongoDB Community server. The latest version can be found here
When installed go into the folder where you've installed mongo and proceed into the bin folder
cd mongo/bin
Start the database server and provide the path to your local data source for the database
./mongod --auth --dbpath ~/mongo-data
If everything went succesfully, the last line in the terminal should be: [initiateandlisten] waiting for connections on port 27017
In a new tab or terminal window you can now connect to the database
./mongo
Since the repo is set up to authenticate when connecting to the db you may need to create a user for the local database
First create a user
> db.createUser(
{
user: '$YOUR_USERNAME',
pwd: '$YOUR_PASSWORD',
roles: [
{ role: 'readWrite', db: 'TouristApi' },
{ role: 'readWrite', db: 'TouristApiTest' }
]
}
)
Next up you need to add the credentials in your local dev.js
file (see below in 2.1 of rmore info on this file)
Now you're ready to run commands. Test your connection by inserting some arbitrary document
> db.TouristApi.insert({name: 'John D Rockefeller'})
You should get a message saying WriteResult({ "nInserted": 1 })
. This means that you have succesfully inserted a document in the database. Yay!
To make sure that everything went ok run the following to retrieve and review the document
> db.TouristApi.find()
When developing you need to enable authentication and store the credentials along with the other API keys needed (see below section below).
When working with the db locally I use Robo 3T to have a graphical UI. If you want ot do the same then you can find the application at their website https://robomongo.org/
To run the application locally you need API keys for the different APIs used and store them in keys/dev.js
The needed API keys are:
The file should export a single object containing the same key value pairs as keys/prod.js
in the config directory
module.exports = {
MONGO_USER: $YOUR_LOCAL_MONGO_USER,
MONGO_PWD: $YOUR_LOCAL_MONGO_PASSWORD,
CURRENCY_LAYER_API_KEY: $YOUR_CURRENCY_LAYER_API_KEY,
FIXER_API_KEY: $YOUR_FIXER_API_KEY
}