Пример #1
0
var Method = require('aeolus').Method;
var pg = require('pg');

var conString = require('../../util/DBUrl.js');

var projects = new Method();

var run = function(subdomain) {
  //do something!
  console.log("Starting!");
};

var setRunning = function(user, subdomain, callback) {
  pg.connect(conString, function(err, client, done) {
    if (err) {
      return console.error('error fetching client from pool', err);
    }
    client.query('UPDATE Projects SET running = true WHERE user = ' + user + ' and subdomain = ' + subdomain, function(err, result) {
      if (err) {
        client.query('CREATE TABLE Projects (repo varchar(255) NOT NULL, user varchar(255) NOT NULL, subdomain varchar(255) NOT NULL, running boolean, PRIMARY KEY (subdomain))');
        callback();
      }
      done();
      callback();
    });
  });
};

projects.handle(function(request, response) {
  var subdomain = request.getParameter('project');
  setRunning(request.getUsername(), subdomain, function() {
var Method = require('aeolus').Method;
var pg = require('pg');

var conString = require('../../util/DBUrl.js');

var projects = new Method();

var findProjectsByUser = function(user, callback) {
  pg.connect(conString, function(err, client, done) {
  if(err) {
    return console.error('error fetching client from pool', err);
  }
  client.query('SELECT * FROM Projects WHERE user = ' + user, function(err, result) {
    if(err) {
      client.query('CREATE TABLE Projects (repo varchar(255) NOT NULL, user varchar(255) NOT NULL, subdomain varchar(255) NOT NULL, running boolean, PRIMARY KEY (subdomain))');
      callback(false);
    }
    done();
    if (result.rows.length === 1) {
      callback(result.rows[0].running);
    } else {
      callback(false);
    }
  });
});
};

projects.handle(function(request,response) {
  findProjectsByUser(request.getUsername(), function(projects) {
    response.respondJSON(projects);
  });
Пример #3
0
var Method = require('aeolus').Method;

var user = new Method();

user.handle(function(request, response) {
  var name = request.getParameter("id");
  response.respondPlainText("Hello, " + name);
});

module.exports = user;
Пример #4
0
var Method = require('aeolus').Method;

var hello = new Method();

hello.handle(function(request, response) {
  response.respondPlainText("Performed DELETE on /hello");
});

// This Method requires Authentication

hello.setHasAuth(true);

module.exports = hello;