seedlinux

find open source torrents and stats for people wishing to contribute bandwidth.
git clone git://git.beardyjay.co.uk/seedlinux
Log | Files | Refs | README | LICENSE

commit 460ccb911113e7fd76ad8a34fe6b5acf9420eab8
parent 5a77775070ce4a5e619f682983dfe710585ae683
Author: Jay Scott <jay@beardyjay.co.uk>
Date:   Thu,  6 Jul 2017 13:04:49 +0100

Adding gzip compression, updating routes.

I am adding gzip compression for obvious reasons but also
removing the /torrent route as its really not needed.

Diffstat:
Mapp.js | 4++--
Mbin/parse | 3++-
Mcontrollers/torrents_controller.js | 2+-
Mpackage.json | 1+
Mroutes/index.js | 3++-
Droutes/torrent_route.js | 10----------
6 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/app.js b/app.js @@ -7,9 +7,9 @@ const cookieParser = require('cookie-parser'); const bodyParser = require('body-parser'); const mongoose = require('mongoose'); const helmet = require('helmet'); +const compression = require('compression'); const config = require('./app/config'); -const torrent = require('./routes/torrent_route'); const index = require('./routes/index'); const mongoDB = config.dbURI; @@ -27,6 +27,7 @@ app.use(helmet({ hsts: false })); +app.use(compression()); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); @@ -39,7 +40,6 @@ app.use(function(req,res,next){ }); app.use('/', index); -app.use('/torrent/', torrent); app.use(function(req, res, next) { var err = new Error('Not Found'); diff --git a/bin/parse b/bin/parse @@ -5,10 +5,11 @@ console.log('Parsing torrent folder'); const async = require('async'); const mongoose = require('mongoose'); -const mongoDB = process.env.DB_URI; const parseTorrent = require('parse-torrent'); const Torrent = require('../models/torrent_model'); const fs = require('fs'); +const config = require('../app/config'); +const mongoDB = config.dbURI; const torrentFolder = './data/torrents'; diff --git a/controllers/torrents_controller.js b/controllers/torrents_controller.js @@ -137,7 +137,7 @@ exports.torrent_update = function(req, res) { else if (err) res.sendStatus(500); else - res.redirect('/torrent/details/' + req.params.id); + res.redirect('/details/' + req.params.id); } ); }; \ No newline at end of file diff --git a/package.json b/package.json @@ -11,6 +11,7 @@ "dependencies": { "async": "^2.5.0", "body-parser": "^1.17.2", + "compression": "^1.6.2", "cookie-parser": "^1.4.3", "debug": "^2.6.8", "express": "^4.15.3", diff --git a/routes/index.js b/routes/index.js @@ -5,5 +5,6 @@ const router = express.Router(); const torrent_controller = require('../controllers/torrents_controller'); router.get('/', torrent_controller.index); - +router.get('/details/:id', torrent_controller.torrent_detail); +router.get('/update/:id', torrent_controller.torrent_update); module.exports = router; diff --git a/routes/torrent_route.js b/routes/torrent_route.js @@ -1,10 +0,0 @@ -'use strict'; - -const express = require('express'); -const router = express.Router(); -const torrent_controller = require('../controllers/torrents_controller'); - -router.get('/details/:id', torrent_controller.torrent_detail); -router.get('/update/:id', torrent_controller.torrent_update); - -module.exports = router;