Sample APIS - For mobile app such as close5
This application contains some sample APIS which can be used by mobile apps such as close5.
Prerequisite : Understanding of nodejs, ES6 High order function
Please make sure nodejs version that you are using supports ES6 features such as arrow function. You can use node version 4.x or above or babel module for ES6 features.
Here are details of APIs.
-
/items/:id
This API returns item for given id.
Request Type : GET
Using curl: curl http://localhost:3000/items/5421c0eb3f37951d5c000019/
-
/items
This API returns items and response can be filtered using different query parmeters
Request Type : GET
Valid query parameters: lattitude, longitude, radius, userId, sortBy (price, date), sortOrder (A - for Ascending , D - for Descending)
Using curl:
Returns all the items by default dorted by created date in ascending order
Returns items having passed userId
Returns all the items belonging to passed userId and within 50 miles range of passed coordinates
Returns all the items belonging to passed userId and within 50 miles range of passed coordinates and returned data is sorted by price in descending order
-
Download this repo.
-
cd into this folder on your system terminal.
-
run "npm install"
-
run "node server.js" or "npm start"
-
Server starts on port 3000 by defulat. To use any of above api, append it to "http://localhost:3000". e.g. "http://localhost:3000/items/".
-
Use any REST client (see curl example in service description) to verify implementation. Please pass parameters as mentioned above.
-
run "npm test" to run test cases
-
Standard boilerplate for a nodejs server
-
Unified logging
-
Cron job to remove log file content everyday
-
Unit testing Using Mocha, Chai and Supertest
-
Use of ES6 high order function