Run steps
- Installed nodejs, mongodb and mongodb is running
npm install
oryarn install
- Start API server
node index.js
orPORT=xxxx node index.js
- Create new user
-
endpoint:
http://localhost:8899/user
(if running with another port please replace 8899 by your port) -
method: POST
-
data: JSON (username, password, answers fields is required), following is example of POST data
{ "firstName": "John", "lastName": "smith", "email": "js@js.com", "username": "admin", "password": "admin123", "answers": [{"question": "saving", "choice": 10000}, {"question": "loaning", "choice": 8000}] }
-
response: JSON following is example of response
{ "error": null, "data": { "_id": "5b0d21514c55b31dba35bd57", "firstName": "John", "lastName": "smith", "email": "js@js.com", "username": "admin", "password": "$2b$10$hoE/RATAUYQEwokppJnd/.47mXriMA6WMMBGCGhc36vGX1VV2FZ8q", "rank": "B", "created": "2018-05-29T09:45:53.508Z", "__v": 0 } }
-
- Enjoy
- Notes: Tested on Archlinux with nodejs 10.2.1, mongodb 3.6.4
TODOs - Make Question as a model.