Coder Social home page Coder Social logo

express-mongodb-api's Introduction

Example express api and mongodb geonear

Example of searching for nearest driver of your point

Install

$ git clone https://github.com/asalih/express-mongodb-api.git
$ cd express-mongodb-api
$ npm install

4. Before you go;

You must set your mongodb connection string into ./helpers/config config.mongodb.connectionString

$ npm start

navigate to http://localhost:1337

Module Used

  • express
  • mongoose
  • mocha
  • chai

API

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.

Test

Testing for few scenarios npm test

express-mongodb-api's People

Contributors

asalih avatar dependabot[bot] avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.