summaryrefslogtreecommitdiffstats
path: root/lib/utils/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils/server.js')
-rw-r--r--lib/utils/server.js32
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/utils/server.js b/lib/utils/server.js
index 2b97fe8..1d6822f 100644
--- a/lib/utils/server.js
+++ b/lib/utils/server.js
@@ -1,11 +1,9 @@
-var Q = require('q');
-var _ = require('lodash');
-
-var events = require('events');
-var http = require('http');
-var send = require('send');
-var util = require('util');
-var url = require('url');
+var Q = require("q");
+var events = require("events");
+var http = require("http");
+var send = require("send");
+var util = require("util");
+var url = require("url");
var Server = function() {
this.running = null;
@@ -17,7 +15,7 @@ util.inherits(Server, events.EventEmitter);
// Return true if the server is running
Server.prototype.isRunning = function() {
- return this.running != null;
+ return !!this.running;
};
// Stop the server
@@ -57,25 +55,25 @@ Server.prototype.start = function(dir, port) {
res.end(err.message);
}
- // Redirect to directory's index.html
+ // Redirect to directory"s index.html
function redirect() {
res.statusCode = 301;
- res.setHeader('Location', req.url + '/');
- res.end('Redirecting to ' + req.url + '/');
+ res.setHeader("Location", req.url + "/");
+ res.end("Redirecting to " + req.url + "/");
}
// Send file
send(req, url.parse(req.url).pathname)
.root(dir)
- .on('error', error)
- .on('directory', redirect)
+ .on("error", error)
+ .on("directory", redirect)
.pipe(res);
});
- that.running.on('connection', function (socket) {
+ that.running.on("connection", function (socket) {
that.sockets.push(socket);
socket.setTimeout(4000);
- socket.on('close', function () {
+ socket.on("close", function () {
that.sockets.splice(that.sockets.indexOf(socket), 1);
});
});
@@ -91,6 +89,6 @@ Server.prototype.start = function(dir, port) {
return d.promise;
});
-}
+};
module.exports = Server;