diff --git a/src/ApiAxle/Shared/Utilities.php b/src/ApiAxle/Shared/Utilities.php index 02024a4..f62ffd6 100644 --- a/src/ApiAxle/Shared/Utilities.php +++ b/src/ApiAxle/Shared/Utilities.php @@ -67,6 +67,16 @@ public static function callApi($apiPath, $method='GET', $data=null, $config) $request = HttpRequest::request($url, $method, $json_data, $headers, $config); if($request){ $results = json_decode($request); + + // If unable to decode the response as JSON... + if (is_null($results)) { + + // Throw an exception, suggesting to the user that the problem + // may be that ApiAxle is not running. + throw new \ErrorException('API did not return properly. ' . + 'Is ApiAxle running?'); + } + if($results->meta->status_code >= 200 && $results->meta->status_code < 300){ return $results->results; } elseif($results->meta->status_code >= 300 && $results->meta->status_code < 400){ diff --git a/vagrant-setup.sh b/vagrant-setup.sh index 6924549..bd73fb0 100755 --- a/vagrant-setup.sh +++ b/vagrant-setup.sh @@ -1,10 +1,18 @@ #!/bin/bash +# Create some swap space. +sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 +sudo /sbin/mkswap /var/swap.1 +sudo /sbin/swapon /var/swap.1 + +# Add the necessary entry/entries to the hosts file. +sudo echo 127.0.0.1 apiaxle.api.local >> /etc/hosts + # Install necessary packages sudo add-apt-repository -y ppa:chris-lea/node.js sudo apt-get update -y sudo apt-get install -y git python-software-properties build-essential libxml2-dev nodejs redis-server php5 php5-curl -sudo npm install -g apiaxle-base apiaxle-repl apiaxle-proxy apiaxle-api +sudo npm install -g sinon twerp apiaxle-base@1.10 apiaxle-repl@1.10 apiaxle-proxy@1.10 apiaxle-api@1.10 # Start ApiAxle processes apiaxle-proxy -p 3000 &