From 588c01522be3efad901cff124750ec6895166c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Dahlgren?= Date: Thu, 5 Jun 2014 00:17:18 +0200 Subject: [PATCH] Implemented toJSON on server object --- manager.js | 12 +++++++++++- routes/servers.js | 22 +++------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/manager.js b/manager.js index 68bcee5..b5bf715 100644 --- a/manager.js +++ b/manager.js @@ -91,7 +91,17 @@ Server.prototype.stop = function(cb) { }, 5000); return this; -} +}; + +Server.prototype.toJSON = function () { + return { + id: this.id, + title: this.title, + port: this.port, + mods: this.mods, + pid: this.pid, + }; +}; function Manager() { this.serversArr = []; diff --git a/routes/servers.js b/routes/servers.js index c5046f4..93fe98b 100644 --- a/routes/servers.js +++ b/routes/servers.js @@ -41,13 +41,7 @@ exports.create = function (req, res){ exports.show = function (req, res){ var server = manager.getServer(req.params.server); - res.send({ - id: server.id, - title: server.title, - port: server.port, - mods: server.mods, - pid: server.pid, - }); + res.send(server); }; exports.update = function(req, res){ @@ -67,20 +61,10 @@ exports.update = function(req, res){ manager.save(); } - res.send({ - id: server.id, - title: server.title, - port: server.port, - mods: server.mods, - }); + res.send(server); }); } else { - res.send({ - id: server.id, - title: server.title, - port: server.port, - mods: server.mods, - }); + res.send(server); } };