From 789a51c6e27fa39acbc2caa71c9f9d20421fe54f Mon Sep 17 00:00:00 2001 From: William Mantly Date: Sun, 16 Feb 2020 12:17:20 -0500 Subject: [PATCH] mvp --- app.js | 27 ++++++++++----------------- package.json | 3 --- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/app.js b/app.js index d18bffc..4edc0df 100644 --- a/app.js +++ b/app.js @@ -11,30 +11,23 @@ const port = process.env.NODE_PORT || '3000'; const inject = fs.readFileSync('./inject.html', 'utf8'); const Transmission = require('transmission-promise') -let tr_client = new Transmission({ +var tr_client = new Transmission({ host:'192.168.1.176', - // port: , username: 'william', - // password: 'palm7', - // ssl: true + password: 'palm7', }) -tr_client.on('ready', console.log) +app.post("/__api/torrent", async function(req, res, next){ -tr_client.on('error', console.log) + if(req.body.api !== '4412') return res.status(421); + try{ + let cres = await tr_client.addUrl(Buffer.from(req.body.magnet, 'base64').toString('binary')); + console.log(cres) -app.post("/__api/torrent", function(req, res, next){ - - console.log('api', req.body) - - tr_client.addUrl(Buffer.from(req.body.magnet, 'base64').toString('binary')).then(function(data){ - console.log(data) - res.status('200') - }).error(function(err){ - console.error(err) - res.status('500').json({}) - }); + }catch(e){ + console.error('error', e) + } }); app.all("/*.js", function(req, res){res.send('')}); diff --git a/package.json b/package.json index 95d5c74..0bd1ccf 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,7 @@ "license": "ISC", "dependencies": { "express": "^4.17.1", - "express-request-proxy": "^2.2.2", "http-proxy-middleware": "^0.20.0", - "node-transmission": "^1.1.0", - "nodemon": "^2.0.2", "transmission-promise": "^1.1.4" } }