Example of searching for nearest driver of your point
$ git clone https://github.com/asalih/express-mongodb-api.git
$ cd express-mongodb-api
$ npm install
You must set your mongodb connection string into
./helpers/config
config.mongodb.connectionString
$ npm start
navigate to http://localhost:1337
- express
- mongoose
- mocha
- chai
POST /ride
waits coordinates in request body, like below. if you send maxDistance then searchs with this distance but if you don't, distance will be setting up with config.settings.defaultMaxDistance
.
//ride endpoint post body
//maxDistance is optional
{
"maxDistance": 1000,
"coordinates": [40.993017, 29.072253]
}
you can set the result size config.settings.defaultNearDriverCount
.
GET /drivers
List of drivers. If has more than config.settings.defaultResultLimit
then result will be {hasNextPage:true, drivers:[...]}
. For next page GET /drivers/1
. Default page is 0.
//Driver Model
{
"fullName": "Ahmet Salih",
"rate": 4.7,
"car": "Toyota",
"location": {
"type": "Point",
"coordinates": [40.993017, 29.072253]
}
}
POST /driver
Creates new driver with posted body.GET /driver/:id
Gets driver with the given id.PUT /driver/:id
Updates driver with posted body.DELETE /driver/:id
Deletes driver with the given id.
Testing for few scenarios npm test