-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
48 lines (35 loc) · 1.2 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
// Generated by CoffeeScript 1.7.1
(function() {
var action, app, bikeShare, bodyParser, endpoints, express, middleware, morgan, point, utils, ware, _i, _len;
bodyParser = require('body-parser');
express = require('express');
morgan = require('morgan');
bikeShare = require('./lib/bikeShare.js');
utils = require('./lib/utils.js');
endpoints = {
'/bikeshare/stations': function(req, res) {
return bikeShare.allStations(req, res);
},
'/bikeshare/stations/:lat/:long': function(req, res) {
return bikeShare.closestStations(req, res);
},
'/bikeshare/city/:city': function(req, res) {
return bikeShare.cityStations(req, res);
},
'/bikeshare/city/:city/:lat/:long': function(req, res) {
return bikeShare.closestStations(req, res);
}
};
middleware = [morgan('dev'), bodyParser.json(), utils.allowCrossDomain, express["static"]("" + __dirname + "/public")];
app = express();
for (point in endpoints) {
action = endpoints[point];
app.get(point, action);
}
for (_i = 0, _len = middleware.length; _i < _len; _i++) {
ware = middleware[_i];
app.use(ware);
}
app.listen(8080);
console.log('server running');
}).call(this);