louisthomaspro / triathlon-api

Web applications allowing the management of stocks of several stores.

Home Page:https://triathlon-api.herokuapp.com/api/v1/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API Platform

Triathlon API

Web applications allowing the management of stocks of several stores. Several roles are available:

  • Administrator (management of all stores)
  • Store manager (product and seller management for his store)
  • Seller (management of the quantity of stock in his store)

The front application is available here.

Installation

  1. Clone
git clone https://github.com/louisthomaspro/triathlon-api
cd triathlon-api
  1. Run docker-compose
docker-compose up -d
  1. Load fixtures (mockdata)
docker-compose exec php bin/console hautelook:fixtures:load --purge-with-truncate -n --no-bundles
  1. Find the API Swagger documentation at : https://localhost:8443/api/v1/docs

  2. GĂ©nerate a token

curl -X POST \
  https://localhost:8443/api/v1/login \
  -k \
  -H 'Content-Type: application/json' \
  -H 'Host: localhost:8443' \
  -H 'cache-control: no-cache' \
  -d '{"email":"louisthomas.pro@gmail.com","password":"coucou"}'
  1. You can test with multiple roles accounts (password always "coucou")
  1. For a better experience, install Triathlon-front

Useful commands

Recreate the database

docker-compose exec php bin/console --env=prod doctrine:schema:drop --full-database --force && docker-compose exec php bin/console doctrine:schema:update --force

Update the database

docker-compose exec php bin/console doctrine:schema:update --force

Create/update an entity

docker-compose exec php bin/console make:entity --api-resource

Problem of rigths ?

sudo chown -R $(whoami) triathlon-api/

Clear you repo

git rm --cached .-r

Generate manually the JWT files

docker-compose exec php sh -c '
    set -e
    apk add openssl
    mkdir -p config/jwt
    jwt_passhrase=$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')
    echo "$jwt_passhrase" | openssl genpkey -out config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
    echo "$jwt_passhrase" | openssl pkey -in config/jwt/private.pem -passin stdin -out config/jwt/public.pem -pubout
    setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
    setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt

'

When deplying on a server (say yeeees)

composer require symfony/apache-pack

Heroku commands

You have to install Heroku CLI for the next commands

Heroku without CI/CD (in 'api' folder)

heroku run bash -a triathlon-api
php bin/console doctrine:schema:create
heroku config:set APP_ENV=prod
git add --all
git commit -a -m "My first API Platform app running on Heroku!"
heroku git:remote -a triathlon-api
git push heroku master

Heroku github login

heroku auth:token
username: blank
password: token

Load local data to Heroku

  1. Make a backup
docker-compose exec db pg_dump -U api-platform api --no-owner --no-acl -f backup.sql
  1. Copie the sql file generated to local
docker cp CONTAINER_ID:/backup.sql ./backup.sql
  1. Load the sql file to the server
heroku pg:psql --app triathlon-api < ./backup.sql 

About

Web applications allowing the management of stocks of several stores.

https://triathlon-api.herokuapp.com/api/v1/docs

License:MIT License


Languages

Language:JavaScript 66.7%Language:PHP 19.3%Language:Dockerfile 4.6%Language:CSS 3.5%Language:HTML 2.1%Language:Shell 1.9%Language:VCL 1.3%Language:Smarty 0.5%