-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (27 loc) · 844 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* FoodTruckr - Server.
* See the readme for a detailed description of this application
*/
var express = require('express'),
config = require('./config'),
app = express(),
truckController = require('./controller/truckController'),
TruckCache = require('./util/truckCache');
if(config.port === undefined){
console.error('Please source appropiate .env file before running');
return;
}
// enable cors access
app.use(function(req, res, next){
res.header('Access-Control-Allow-Origin','*');
next();
});
// configure routes to the controllers
app.get('/findInRect/:lat1/:lng1/:lat2/:lng2', truckController.findInArea);
// geohashes trucks into redis
var truckCache = new TruckCache();
truckCache.initialize();
app.listen(config.port,function(){
console.log('Listening on port ', config.port);
});
module.exports = app;