-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
61 lines (49 loc) · 1.41 KB
/
app.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, path = require('path')
, api = require('./routes/api');
var app = express();
// all environments
app.set('port', process.env.PORT || 8888);
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
if ('production' !== process.env.status) {
// development only
app.set('views', __dirname + '/app');
app.use(express.static(path.join(__dirname, 'app')));
app.use(function(req, res) {
res.render('index.html', { title: 'MovieMap' });
});
app.use(express.errorHandler());
} else {
// production
app.set('views', __dirname + '/dist');
app.use(express.static(path.join(__dirname, 'dist')));
app.use(function(req, res) {
res.render('index.html', { title: 'MovieMap' });
});
}
/**
* OSM API
*/
app.get('/geocode/name/:name', api.geocode);
app.get('/reverse/:lat/:lng', api.reverse);
/**
* Freebase API
*/
// test: {lat:40.7144,lng:-74.006}
app.get('/freebase/lat/:lat/lng/:lng', api.freebase_coords);
app.get('/freebase/topic/:name', api.freebase_topic);
app.get('/', routes.index);
module.exports = app;
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});