var async = require('async');
var express = require('express');
var router = express.Router();

var Cantina = require("../libs/cantina");
var Coffee = require("../libs/coffee");
var Hackerspace = require("../libs/hackerspace");
var Light = require("../libs/light");
var Meeting = require("../libs/meeting");
var Event = require("../libs/event");
var Servant = require("../libs/servant");

var httpErrorStatus = function(data, res) {
  if(data.error) {
    res.status(400);
  }
};

router.route('/office/:affiliation').get(function(req, res) {
  async.parallel([
    function(callback) {
      var meeting = new Meeting();
      meeting.get(req.params.affiliation, function(data) {
        callback(null, {name: 'meeting', value: data});
      });
    },
    function(callback) {
      var servant = new Servant();
      servant.get(req.params.affiliation, function(data) {
        callback(null, {name: "servant", value: data});
      });
    },
    function(callback) {
      var coffee = new Coffee();
      coffee.get(req.params.affiliation, function(data){
        callback(null, {name: 'coffee', value: data});
      });
    },
    function(callback) {
      var event = new Event();
      event.get(req.params.affiliation, function(data) {
        callback(null, {name: 'event', value: data});
      });
    },
    function(callback) {
      var light = new Light();
      light.get(req.params.affiliation, function(data) {
        callback(null, {name: 'status', value: data});
      });
    }
    ],
    function(err, results) {
      var data = {};
      results.forEach(function(result) {
        data[result.name] = result.value;
      });
      res.json(data);
    }
    );  
});

router.route('/hackerspace').get(function(req, res) {
  var hackerspace = new Hackerspace();
  hackerspace.get(function(data) {
    httpErrorStatus(data, res);
    res.json(data);
  });
});

router.route('/cantina/:location').get(function(req, res) {
  var cantina = new Cantina();
  cantina.get(req.params.location, function(data) {
    httpErrorStatus(data, res);
    res.json(data);
  });
});

module.exports = router;

@@ -386,100 +386,8 @@
 );%0A%0A
-var httpErrorStatus = function(data, res) %7B%0A  if(data.error) %7B%0A    res.status(400);%0A  %7D%0A%7D;%0A%0A
 rout
@@ -1726,40 +1726,8 @@
 ) %7B%0A
-    httpErrorStatus(data, res);%0A
     
@@ -1900,40 +1900,8 @@
 ) %7B%0A
-    httpErrorStatus(data, res);%0A
     

Remove unnecessary http 400 bad request response