#Minutrade Client API
- Windows : http://nodejs.org/download/
- Mac : http://nodejs.org/download/
- Ubuntu 14.04 (for other distribution : Documentation Node Linux)
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
In command line:
npm install
In command line:
- Windows:
C:\Program Files\MongoDB\bin\mongod.exe
Mac:
mongod
Ubuntu:
sudo service mongod start
In command line:
node index.js
In command line:
npm install mocha -g
mocha test/utils/ClientValidator.js
It was hard for me to see the scope outside of this test. More information about the context and the future use of this API could have narrowed my choice between RDBMS or NoSQL and my choice for a REST API framework. Since I didn't have this information, I decided to have fun with this test and to learn something new. I choose MongoDB and NodeJS because I never use those before and I've heard a lot about it. For a small project like that, I would probably have used Spring MVC for the REST API because I am used to it (which is not a very good reason in a professional context) and I would have implemented my data layer using JSON in text files because for something that small, it removes some dependencies and it is easier to implement. I really enjoyed using MongoDB and I think for anything that is CRUD and will scale horizontaly, it is an interesting option.
Use something like Advanced REST client to do the following calls:
GET
localhost:3000/clients
GET
localhost:3000/clients/:cpf
POST
localhost:3000/clients
Example of body:
{"cpf":"11438374798","name":"test","email":"[email protected]","maritalStatus":"single","address":"123 rue des Saules","phoneNumbers": ["11231234567", "11231234560"]}
IMPORTANT: I wasn't sure of all the validation to be done on each field so I did my best and I made it easy to change: just go to utils/ClientValidator.js and modify the private method validating the corresponding field.
DELETE
localhost:3000/clients/:cpf