GithubHelp home page GithubHelp logo

louisthomaspro / triathlon-api Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 3.08 MB

Web applications allowing the management of stocks of several stores.

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

License: MIT License

Dockerfile 4.57% HTML 2.06% JavaScript 66.72% PHP 19.35% Shell 1.90% VCL 1.31% Smarty 0.54% CSS 3.54%

triathlon-api's Introduction

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":"[email protected]","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 

triathlon-api's People

Contributors

louisthomaspro avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

triathlon-api's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.