diff options
Diffstat (limited to 'routes/api/remoteVideos.js')
-rw-r--r-- | routes/api/remoteVideos.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/routes/api/remoteVideos.js b/routes/api/remoteVideos.js new file mode 100644 index 000000000..eed586d23 --- /dev/null +++ b/routes/api/remoteVideos.js | |||
@@ -0,0 +1,29 @@ | |||
1 | ;(function () { | ||
2 | 'use strict' | ||
3 | |||
4 | var express = require('express') | ||
5 | var router = express.Router() | ||
6 | var middleware = require('../../middlewares') | ||
7 | var videos = require('../../src/videos') | ||
8 | |||
9 | function addRemoteVideos (req, res, next) { | ||
10 | videos.addRemote(req.body.data, function (err, video) { | ||
11 | if (err) next(err) | ||
12 | |||
13 | res.json(video) | ||
14 | }) | ||
15 | } | ||
16 | |||
17 | function removeRemoteVideo (req, res, next) { | ||
18 | videos.removeRemote(req.body.signature.url, req.body.data.magnetUri, function (err) { | ||
19 | if (err) next(err) | ||
20 | |||
21 | res.status(204) | ||
22 | }) | ||
23 | } | ||
24 | |||
25 | router.post('/add', middleware.cache(false), middleware.decryptBody, addRemoteVideos) | ||
26 | router.post('/remove', middleware.cache(false), middleware.decryptBody, removeRemoteVideo) | ||
27 | |||
28 | module.exports = router | ||
29 | })() | ||