-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
27 lines (22 loc) · 939 Bytes
/
server.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
var restify = require('restify');
var mediaPlayer = require("media-player");
var mediaLibrary = require("plex");
// Startup REST server and setup request mappings
var server = restify.createServer({name: 'NodeMediaCenter'});
// Media Player API
server.use(restify.bodyParser());
server.post('/api/player/play', mediaPlayer.play);
server.post('/api/player/stop', mediaPlayer.stop);
server.post('/api/player/pause', mediaPlayer.pause);
// Media Library API
server.get('/api/media/tvshows', mediaLibrary.getAllTvShows);
server.get('/api/media/children/:key', mediaLibrary.getChildrenByKey);
server.post('/api/media/watched/:key', mediaLibrary.flagAsWatched);
server.post('/api/media/unwatched/:key', mediaLibrary.flagAsUnwatched);
// Static content (GUI)
server.get(/\/gui\/?.*/, restify.serveStatic({
directory: './static'
}));
server.listen(8080, function() {
console.log('%s listening at %s', server.name, server.url);
});