Skip to content

ArthurJCQ/KillerAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Killer API

This code runs the API of https://killerparty.app

Installation

Requirements

Make sure that you have composer and PHP 8.2 minimum installed on your system.

Docker compose is recommended for database, although you can use PostgreSQL without container if you rather.

You will have to install Mercure binary as well.

Install dependencies

$ composer install

Set up database

Run database with docker-compose file :

$ docker-compose up -d

... Or with any other way you choose.

Then, create your database using this command :

$ bin/console doctrine:database:create

And run migrations (you can use quick notation as follow) :

$ bin/console do:mi:mi

Generate Keypair for JWT Authentication

This API is using JWT tokens to authenticate clients. A keypair must be generated in order to sign these JWTs. To do so, run :

$ bin/console lexik:jwt:generate-keypair --overwrite

Mercure

To use SSE events with Mercure, start with downloading Mercure binary on the github release page, according to your dev environment.

Unzip the archive anywhere your want in your PC (not in this project). Then, open Caddyfile.dev and add this line above the route { directive :

header Access-Control-Allow-Origin http://YOU-FRONT-END-APP-DOMAIN:PORT

To launch mercure, just launch this command :

$ MERCURE_PUBLISHER_JWT_KEY='dev-@1123581321-killer-mercure-secret' \
MERCURE_SUBSCRIBER_JWT_KEY='dev-@1123581321-killer-mercure-secret' \
./mercure run --config Caddyfile.dev

MERCURE_PUBLISHER_JWT_KEY & MERCURE_SUBSCRIBER_JWT_KEY must have the same value as the MERCURE_JWT_SECRET in your .env.

Check Mercure on this url : https://localhost/.well-known/mercure/ui/

You may have to authorize unsecure https on this domain.

Running the Symfony API

If you have the Symfony CLI, just run :

$ symfony serve

Otherwise, use just php and run :

$ php -S 127.0.0.1:8000 -t public

Tests & Static analysis

A Makefile is provided to ease tests & static analysis commands.

PHPcs

$ make phpcs

PHPstan

$ make phpstan

PHPstan

$ make phpstan

Unit tests

$ make unit-tests

Functional tests

$ make functional-tests