{"size": 767, "ext": "js", "max_stars_repo_path": "ems-server/server/boot/store.js", "max_stars_repo_name": "toni240598/ems-angular2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ems-server/server/boot/store.js", "max_issues_repo_name": "toni240598/ems-angular2", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ems-server/server/boot/store.js", "max_forks_repo_name": "toni240598/ems-angular2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.5588235294, "max_line_length": 76, "alphanum_fraction": 0.5880052151}
'use strict';

module.exports = function(server) {
  // Install a `/` route that returns server status
  var router = server.loopback.Router();
  router.get("/api/store/:latitude/:longitude",(req,res)=>{
		let latitude = parseFloat(req.params.latitude);
		let longitude = parseFloat(req.params.longitude);

	  	Build();
	  	function Build(){
	  		let service = new Service();
	  		service.store().then(store=>{
	  			res.send(store);	
	  		})
	  		
	  	}

	  	function Service(){
	  		this.store = function(){
	  			return server.models.location.find({
	  				where : {latitude : latitude, longitude : longitude, type : 'store' }
	  			})
	  			.then(result=>{
	  				let store = result[0];
	  				return store;
	  			})
	  		}
	  	}	

  });
  server.use(router);
};
