diff --git a/.gitignore b/.gitignore index 62803556..417ddcd4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,11 +21,11 @@ build/Release # Dependency directories node_modules bower_components -server/vendor +api/vendor # Build files build -server/composer.lock +api/composer.lock .idea .jshintrc diff --git a/server/composer.json b/api/composer.json similarity index 100% rename from server/composer.json rename to api/composer.json diff --git a/server/config.php b/api/config.php similarity index 100% rename from server/config.php rename to api/config.php diff --git a/server/controllers/user.php b/api/controllers/user.php similarity index 100% rename from server/controllers/user.php rename to api/controllers/user.php diff --git a/server/index.php b/api/index.php similarity index 100% rename from server/index.php rename to api/index.php diff --git a/server/libs/Controller.php b/api/libs/Controller.php similarity index 100% rename from server/libs/Controller.php rename to api/libs/Controller.php diff --git a/server/models/DataStore.php b/api/models/DataStore.php similarity index 100% rename from server/models/DataStore.php rename to api/models/DataStore.php diff --git a/server/models/ERRORS.php b/api/models/ERRORS.php similarity index 100% rename from server/models/ERRORS.php rename to api/models/ERRORS.php diff --git a/server/models/Response.php b/api/models/Response.php similarity index 100% rename from server/models/Response.php rename to api/models/Response.php diff --git a/server/models/Session.php b/api/models/Session.php similarity index 100% rename from server/models/Session.php rename to api/models/Session.php diff --git a/server/models/User.php b/api/models/User.php similarity index 100% rename from server/models/User.php rename to api/models/User.php diff --git a/server/tests/__lib__/Mock.php b/api/tests/__lib__/Mock.php similarity index 100% rename from server/tests/__lib__/Mock.php rename to api/tests/__lib__/Mock.php diff --git a/server/tests/__mocks__/RedBeanMock.php b/api/tests/__mocks__/RedBeanMock.php similarity index 100% rename from server/tests/__mocks__/RedBeanMock.php rename to api/tests/__mocks__/RedBeanMock.php diff --git a/server/tests/__mocks__/SlimMock.php b/api/tests/__mocks__/SlimMock.php similarity index 100% rename from server/tests/__mocks__/SlimMock.php rename to api/tests/__mocks__/SlimMock.php diff --git a/api/tests/controllers/.gitkeep b/api/tests/controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/api/tests/lib/.gitkeep b/api/tests/lib/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/server/tests/models/DataStoreTest.php b/api/tests/models/DataStoreTest.php similarity index 100% rename from server/tests/models/DataStoreTest.php rename to api/tests/models/DataStoreTest.php diff --git a/server/tests/models/ResponseTest.php b/api/tests/models/ResponseTest.php similarity index 100% rename from server/tests/models/ResponseTest.php rename to api/tests/models/ResponseTest.php diff --git a/gulp/tasks/server.js b/gulp/tasks/server.js index 4ff87948..eef6a3bb 100644 --- a/gulp/tasks/server.js +++ b/gulp/tasks/server.js @@ -17,7 +17,7 @@ gulp.task('server', function() { server.use(express.static(config.buildDir)); // Proxy php server api - server.use('/server', proxy('http://localhost:8080/', { + server.use('/api', proxy('http://localhost:8080/', { forwardPath: function(req, res) { return require('url').parse(req.url).path; } @@ -41,4 +41,4 @@ gulp.task('server', function() { s.listen(config.serverport); -}); \ No newline at end of file +}); diff --git a/server/tests/lib/Mock.php b/server/tests/lib/Mock.php deleted file mode 100644 index 1e8318a9..00000000 --- a/server/tests/lib/Mock.php +++ /dev/null @@ -1,75 +0,0 @@ -function = ($function === null) ? function (){} : $function; - } - - public function __invoke() { - $this->timesCalled++; - $this->lastArgs = func_get_args(); - - return call_user_func_array($this->function, func_get_args()); - } - - public function returns($arg) { - $this->function = function () use ($arg) { - return $arg; - }; - - return $this; - } - - public function hasBeenCalled() { - return !!$this->timesCalled; - } - - public function reset() { - $this->timesCalled = 0; - $this->lastArgs = null; - } - - public function hasBeenCalledWithArgs() { - $argumentsMatchAssertion = serialize(func_get_args()) === serialize($this->lastArgs); - - return $this->timesCalled && $argumentsMatchAssertion; - } -} - -class Mock { - public static function stub() { - return new Stub; - } - - public function __construct($arguments = array()) { - if (!empty($arguments)) { - foreach ($arguments as $property => $argument) { - if ($argument instanceOf Closure) { - $this->{$property} = self::stub($argument); - } else { - $this->{$property} = $argument; - } - } - } - } - - public function __set($key, $value){ - if ($value instanceOf Closure) { - $this->{$key} = self::stub($value); - } else { - $this->{$key} = $value; - } - } - - public function __call($method, $arguments) { - if (isset($this->{$method}) && is_callable($this->{$method})) { - return call_user_func_array($this->{$method}, $arguments); - } else { - throw new Exception("Fatal error: Call to undefined method stdObject::{$method}()"); - } - } -} diff --git a/src/lib/APIUtils.js b/src/lib/APIUtils.js index 2b25530b..d8d5350e 100644 --- a/src/lib/APIUtils.js +++ b/src/lib/APIUtils.js @@ -4,7 +4,7 @@ import $ from 'jquery'; const APIUtils = { - root: 'http://localhost:3000/server/', + root: 'http://localhost:3000/api/', getPromise(path, method, data) { return (resolve, reject) => {