-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (33 loc) · 912 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
35
36
37
var restify = require('restify');
var Showtimes = require('showtimes');
/*
* Get current movies that are currently playing
*/
function getCurrentMovies(req, res, next) {
var showtimesApi = new Showtimes(req.params.address, {});
showtimesApi.getMovies((error, movies) => {
if(error) {
next(new Error());
} else {
res.send(movies);
next();
}
});
};
function getNearbyTheaters(req, res, next) {
var showtimesApi = new Showtimes(req.params.address, {});
showtimesApi.getTheaters((error, theaters) => {
if(error) {
next(new Error());
} else {
res.send(theaters);
next();
}
});
};
var server = restify.createServer();
server.get('/movies/:address', getCurrentMovies);
server.get('/theaters/:address', getNearbyTheaters);
server.listen(process.env.PORT || 8080, function() {
console.log('%s listening at %s', server.name, server.url);
});