/sonect-demo

Demo for sonect challenge

Primary LanguageJavaScript

Sonect Challenge

The database contains a list of Postomats around Zurich. We use GeoJSON objects to store the coordinates so we can get advantage of the Geospatial Queries capabilities of mongodb.

API

Once you start the server, to get a list of shops pass the longitude, latitude, radius (in meters) as query parameters in a GET to api/shops/search. You can also sort results using the sortBy query parameter with values of 'distance' or 'withdrawalLimit'. The default is to sort by distance:

Example:

$ curl http://localhost:3000/api/shops/search?longitude=8.5391557&latitude=47.3733028&radius=4000&sortBy=withdrawalLimit

Install dependencies

$ npm install

Seed the database

Make sure your mongodb version is greater than 3.0 and you have installed the dependencies. Then:

$ npm run seed

Run the server

Production:

$ npm start

Developments:

$ npm run start-dev

Tests

Important: Make sure the database is seeded before running the tests.

$ npm test

Gulp task

I created a gulp task to start the server. You need to have the gulp-cli installed:

$ npm install gulp-cli -g

Then, to run the task:

$ gulp