module.exports = function(app){
var cmd = require("cmd-exec").init();
var async = require("async");
var stripAnsi = require('strip-ansi');

app.use(function(req, res, next) {
  next();
});

app.get('/log', function(req, res) {
  res.type('text/json');
  cmd.exec('cat /var/log/arktools/arkserver.log')
  .then(function(result){
    var logs = stripAnsi(result.message);
    logs = decodeURIComponent(logs);
    logs = logs.replace(/\\/g,"/");
    logs = logs.split('\n');
    res.send(JSON.stringify(logs));
  })
  .fail(function(err){
    console.log(err.message);
  })
  .done(function(){
    console.log("successfully returned log to a client");
  });
});

app.get('/checkupdate', function(req, res) {
  res.type('text/json');
  cmd.exec('arkmanager checkupdate')
  .then(function(result){
    var returnMsg = stripAnsi(result.message);
    returnMsg = decodeURIComponent(returnMsg);
    returnMsg = stripAnsi(returnMsg);
    returnMsg = returnMsg.trim();
    returnMsg = returnMsg.split('\n');
    returnMsg.splice(0,1); //remove the 'querying steam database for latest version...' message
    returnMsg.splice(returnMsg.length -1, 1); //remove the 'your server is up to date!' message
    returnMsg.forEach(function( property, i ){
       property = property.split(':');
       property[0] = property[0].toCamelCase();
       property.forEach(function( item, j ) {
          item = item.trim();
          property[j] = item;
       });
       var o = {};
       o[property[0]] = property[1];
       returnMsg[i] = o;
    });
    res.send(JSON.stringify(returnMsg));
  })
  .fail(function(err){
    console.log(err.message);
  })
  .done(function(){
    console.log("successfully returned checkupdate to a client");
  });
});
}

@@ -1723,10 +1723,1050 @@
 %7D);%0A%7D);%0A
+%0Aapp.post('/stop', function(req, res) %7B%0A  res.type('application/json');%0A  cmd.exec('arkmanager stop')%0A  .then(function(result)%7B%0A    var status = stripAnsi(result.message);%0A    status = status.trim();%0A    if(status === %22The server is already stopped%22)%7B%0A%09res.status(300);%0A%09res.send(status);%0A    %7D%0A    else %7B%0A        res.status(201);%0A%09res.send('The server has been stopped');%0A    %7D%0A  %7D)%0A  .fail(function(err)%7B%0A    console.log(err.message);%0A  %7D)%0A  .done(function()%7B%0A    console.log(%22returned status of server stop%22);%0A  %7D);%0A%7D);%0A%0Aapp.post('/start', function(req, res) %7B%0A  res.type('application/json');%0A  cmd.exec('arkmanager start')%0A  .then(function(result)%7B%0A    var status = stripAnsi(result.message);%0A    status = status.trim();%0A    if(status === %22The server is already running%22)%7B%0A%09res.status(300);%0A%09res.send(status);%0A    %7D%0A    else %7B%0A    %09res.status(201);%0A%09res.send('The server is now up');%0A    %7D%0A  %7D)%0A  .fail(function(err)%7B%0A    console.log(err.message);%0A  %7D)%0A  .done(function()%7B%0A    console.log(%22returned status of server start%22);%0A  %7D);%0A%7D);%0A%0A
 %7D%0A

add start and stop POST calls