Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Lumen API of Good Plans made for La nuit de l'info 2019

Notifications You must be signed in to change notification settings

mathrix-education/good-plans-api

Repository files navigation

Mathrix Team Good Plan REST API

Mathrix Good Plan REST API, based on the Lumen framework, edited by Laravel.

Environment Documentation
dev [dev.api.good-plans.mathrix.fr]
master [api.good-plans.mathrix.fr]

Contributors

Database

The linked database is based on mysql/mysql-server To run migrations and seed your own database, you first have to write a .env file following the .env.example file in the root path of the project.

Then, run

php artisan migrate --seed 

The whole database will be generated and filled with mocked data, in order to run functional test.

Documentation

The documentation is based on the OpenAPI specification v3.0.2. The sources files of the documentation are located in the docs/ folder and split across several files. In order to build the actual YAML specification, run

composer docs:compile

The documentation render process uses Redocly/redoc, a node-based OpenAPI renderer. In order to render the documentation, just run:

npx redoc-cli serve docs/output.yaml # serve the documentation on localhost:8080
npx redoc-cli bundle docs/output.yaml -o resources/views/docs/index.html # bundle the documentation into resources/views/docs/index.html

Testing

There are 1 type of tests in this project:

  • API tests (tests/API), which are functional tests ;

Testing is achieved using sebastianbergmann/phpunit.

Since we are using the documentation-driven development strategy which means that we are testing against our documentation, it is necessary to compile the documentation specification before running tests.

phpunit            # runs tests
composer test:cov  # runs tests with code-coverage enable

Deployment

This project is compiled inside a Docker container and deployed through a pipeline using Github Actions.

To generate the corresponding Docker image, run in root path

docker build -t good-plan-api:latest .

Before running the image, make sure you have the following environment variable set. Also, don't forget to seed your database.

Variable Value Default
DB_CONNECTION Type of database used mysql
DB_HOST URL of the database host -
DB_DATABASE Name of the database -
DB_USERNAME Name of the database user -
DB_PASSWORD Password of the corresponding database user -
DB_PORT Port used to reach the database 3306

Then, to run the image

docker run good-plans-api:latest \
  -e "DB_CONNECTION=$db_connection" \
  -e "DB_HOST=$db_host" \
  -e "DB_DATABASE=$db_database" \
  -e "DB_USERNAME=$db_username" \
  -e "DB_PASSWORD=$db_password" \
  -e "DB_PORT=$db_port"

This image will be listen on port 8080 by default.

About

Lumen API of Good Plans made for La nuit de l'info 2019

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published