lots...
This commit is contained in:
42
routes/transmission.js
Normal file
42
routes/transmission.js
Normal file
@@ -0,0 +1,42 @@
|
||||
'use static';
|
||||
|
||||
const router = require('express').Router();
|
||||
const {Torrent} = require('>/models');
|
||||
|
||||
router.get('/', async function(req, res, next){
|
||||
try{
|
||||
res.json({results: await Torrent.findAll({where:{added_by: req.user.username}})});
|
||||
}catch(error){
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
router.post("/", async function(req, res, next){
|
||||
try{
|
||||
res.json(await Torrent.create({...req.body, added_by: req.user.username}))
|
||||
}catch(error){
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/server', async function(req, res, next){
|
||||
try{
|
||||
res.json(await Torrent.trClient.sessionStats())
|
||||
}catch(error){
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/:id", async function(req, res, next){
|
||||
try{
|
||||
let torrent = await Torrent.findByPk(req.params.id);
|
||||
if('latest' in req.query){
|
||||
torrent = await torrent.getTorrentData();
|
||||
}
|
||||
res.json({result: torrent});
|
||||
}catch(error){
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user