From 2d34be9705d96b39cd43370c314dc695360e9ab0 Mon Sep 17 00:00:00 2001 From: Richard Morgan Date: Tue, 16 May 2017 08:06:06 -0400 Subject: [PATCH] update readme and base url used in api response. --- app/Http/Controllers/Controller.php | 2 +- readme.md | 40 +++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 531bf9e..0e35ac8 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -20,7 +20,7 @@ class Controller extends BaseController protected function JsonApiResponse(ResourceInterface $resource, $statusCode, $includes = '') { $manager = app('FractalManager'); - $manager->setSerializer(new JsonApiSerializer('http://docker.dev:8080')); + $manager->setSerializer(new JsonApiSerializer('https://tripbuilder.xai-corp.net')); $manager->parseIncludes($includes); return response()->json($manager->createData($resource)->toArray(), $statusCode); diff --git a/readme.md b/readme.md index 0a7b055..a22b9ba 100644 --- a/readme.md +++ b/readme.md @@ -1,10 +1,15 @@ # Trip Builder -- Richard Morgan +Richard Morgan Test application based on Laravel Lumen 5.4, running on docker containers. -## Launch Environment -The dev environment is docker based. To run the php app, nginx, postgres database, and redis cache containers, simply run docker-compose up +The Response is alway json, in the [json-api](http://jsonapi.org/) format. + +## Dev Environment +The dev environment is docker based. To run the php app, nginx, postgres database, and redis cache containers. + +### launch +simply run docker-compose up ```bash @@ -14,16 +19,41 @@ docker-compose up This will download the required base images, then build the additional tools into new images, and then launch new containers. A container also runs briefly to generate the api docs. -## Setup database +### First run +The zip file contains all the necessary files. If you cloned the git repo, you will need to run composer to +fetch third party packages. + +```bash +docker-compose up composer install +``` + +### Setup database +Before testing the app, you will need to prepare the database. Database migrations and seeds are provided for testing the app. These can be run in docker with the following command: ```bash docker-compose exec app php artisan migrate:refresh --seed ``` +### testing +Some tests are provided, powered by [codeception](http://codeception.com/). + +```bash +docker-compose exec app vendor/bin/codecept run +``` ## Api Documentation +Api documentation is automatically generated using [apidocjs](http://apidocjs.com) within a container. The docker containers expose the api documentation on [http://localhost:8080/docs/](http://localhost:8080/docs/) +As well as describing each api endpoint, the docs include forms for testing the api. -## +You can regenerate the docs with the following command + +```bash +docker-compose up apidocs +``` + +## Testing online +The api is available online at [https://tripbuilder.xai-corp.net](https://tripbuilder.xai-corp.net). +And the docs are available at [https://tripbuilder.xai-corp.net/docs/](https://tripbuilder.xai-corp.net)