mirror of
https://github.com/zoriya/flood.git
synced 2026-06-08 12:42:41 +00:00
Organize models directory
This commit is contained in:
+21
-21
@@ -24,13 +24,13 @@ app.use(cookieParser());
|
||||
app.use(express.static(path.join(__dirname, 'assets')));
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
req.socket.on("error", function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
res.socket.on("error", function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
next();
|
||||
req.socket.on("error", function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
res.socket.on("error", function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
next();
|
||||
});
|
||||
|
||||
app.use('/', routes);
|
||||
@@ -39,9 +39,9 @@ app.use('/client', client);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req, res, next) {
|
||||
var err = new Error('Not Found');
|
||||
err.status = 404;
|
||||
next(err);
|
||||
var err = new Error('Not Found');
|
||||
err.status = 404;
|
||||
next(err);
|
||||
});
|
||||
|
||||
// error handlers
|
||||
@@ -49,23 +49,23 @@ app.use(function(req, res, next) {
|
||||
// development error handler
|
||||
// will print stacktrace
|
||||
if (app.get('env') === 'development') {
|
||||
app.use(function(err, req, res, next) {
|
||||
res.status(err.status || 500);
|
||||
res.render('error', {
|
||||
message: err.message,
|
||||
error: err
|
||||
});
|
||||
app.use(function(err, req, res, next) {
|
||||
res.status(err.status || 500);
|
||||
res.render('error', {
|
||||
message: err.message,
|
||||
error: err
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// production error handler
|
||||
// no stacktraces leaked to user
|
||||
app.use(function(err, req, res, next) {
|
||||
res.status(err.status || 500);
|
||||
res.render('error', {
|
||||
message: err.message,
|
||||
error: {}
|
||||
});
|
||||
res.status(err.status || 500);
|
||||
res.render('error', {
|
||||
message: err.message,
|
||||
error: {}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
var rTorrent = require('./rtorrent');
|
||||
var util = require('util');
|
||||
var ClientUtil = require('./ClientUtil');
|
||||
var FormatUtil = require('./FormatUtil');
|
||||
var clientUtil = require('./util/clientUtil');
|
||||
var formatUtil = require('./util/formatUtil');
|
||||
|
||||
function client() {
|
||||
if((this instanceof client) === false) {
|
||||
@@ -55,29 +55,29 @@ client.prototype.add = function(data, callback) {
|
||||
}
|
||||
|
||||
client.prototype.getTorrentList = function(callback) {
|
||||
rTorrent.get('d.multicall', ClientUtil.defaults.torrentPropertyMethods)
|
||||
rTorrent.get('d.multicall', clientUtil.defaults.torrentPropertyMethods)
|
||||
.then(function(data) {
|
||||
try {
|
||||
// create torrent array, each item in the array being
|
||||
// an object with human-readable property values
|
||||
var torrents = ClientUtil.mapProps(
|
||||
ClientUtil.defaults.torrentProperties,
|
||||
var torrents = clientUtil.mapProps(
|
||||
clientUtil.defaults.torrentProperties,
|
||||
data
|
||||
);
|
||||
// Calculate extra properties.
|
||||
torrents = torrents.map(function(torrent) {
|
||||
torrent.percentComplete = FormatUtil.percentComplete(
|
||||
torrent.percentComplete = formatUtil.percentComplete(
|
||||
torrent.bytesDone,
|
||||
torrent.sizeBytes
|
||||
);
|
||||
|
||||
torrent.eta = FormatUtil.eta(
|
||||
torrent.eta = formatUtil.eta(
|
||||
torrent.downloadRate,
|
||||
torrent.bytesDone,
|
||||
torrent.sizeBytes
|
||||
);
|
||||
|
||||
torrent.status = FormatUtil.status(
|
||||
torrent.status = formatUtil.status(
|
||||
torrent.isHashChecking,
|
||||
torrent.isComplete,
|
||||
torrent.isOpen,
|
||||
@@ -139,13 +139,13 @@ client.prototype.startTorrent = function(hash, callback) {
|
||||
|
||||
client.prototype.getClientStats = function(callback) {
|
||||
try {
|
||||
var request = ClientUtil.createMulticallRequest(ClientUtil.defaults.clientPropertyMethods);
|
||||
var request = clientUtil.createMulticallRequest(clientUtil.defaults.clientPropertyMethods);
|
||||
|
||||
request = [request];
|
||||
|
||||
rTorrent.get('system.multicall', request)
|
||||
.then(function(data) {
|
||||
callback(null, ClientUtil.mapProps(ClientUtil.defaults.clientProperties, data));
|
||||
callback(null, clientUtil.mapProps(clientUtil.defaults.clientProperties, data));
|
||||
}, function(error) {
|
||||
callback(error, null);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
var xmlrpc = require('xmlrpc')
|
||||
var Q = require('q');
|
||||
var net = require('net');
|
||||
var Deserializer = require('./deserializer');
|
||||
var Serializer = require('./serializer');
|
||||
var Deserializer = require('./util/deserializer');
|
||||
var Serializer = require('./util/serializer');
|
||||
|
||||
var rtorrent = {};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var util = require('util');
|
||||
|
||||
var ClientUtil = {
|
||||
var clientUtil = {
|
||||
defaults: {
|
||||
torrentProperties: [
|
||||
'hash',
|
||||
@@ -134,4 +134,4 @@ var ClientUtil = {
|
||||
|
||||
}
|
||||
|
||||
module.exports = ClientUtil;
|
||||
module.exports = clientUtil;
|
||||
@@ -1,5 +1,5 @@
|
||||
var sax = require('sax')
|
||||
, dateFormatter = require('./date_formatter')
|
||||
, dateFormatter = require('./dateFormatter')
|
||||
|
||||
var Deserializer = function(encoding) {
|
||||
this.type = null
|
||||
@@ -1,5 +1,5 @@
|
||||
var xmlBuilder = require('xmlbuilder')
|
||||
, dateFormatter = require('./date_formatter')
|
||||
, dateFormatter = require('./dateFormatter')
|
||||
|
||||
/**
|
||||
* Creates the XML for an XML-RPC method call.
|
||||
@@ -1,7 +1,6 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
/* GET home page. */
|
||||
router.get('/', function(req, res, next) {
|
||||
res.render('index', { title: 'Flood' });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user