Football bet rest/graphql server
Project description
Yak-toto
Requisites
- Ubuntu 22.04
- MySQL 8.0.30
How to build the project
Database
Install and start mysql server on port 3306. Add a database named yak_toto
. In root folder, create a dotenv file named .env
and fill your MySQL user name, password and database. When backend start, this configuration is automaticaly loaded.
MYSQL_USER_NAME=my_user_name
MYSQL_PASSWORD=my_password
MYSQL_DB=my_database_name
You can also set MySQL port by adding MYSQL_PORT=my_port
to .env
file. If not set, it will be 3306 by default.
Backend
Run your project in a Python env is highly recommend. You can use poetry env using the following command:
poetry env use 3.9
poetry shell
Fetch all packages using poetry with the following command:
poetry install
Before starting the backend, add JWT_SECRET_KEY
and JWT_EXPIRATION_TIME
in .env
same as the MySQL user name and password. As
login system is using JSON Web Token, a secret key is required and an expiration time (in seconds). To generate one, you can use the python built-in secrets
module.
>>> import secrets
>>> secrets.token_hex(16)
'9292f79e10ed7ed03ffad66d196217c4'
JWT_SECRET_KEY=9292f79e10ed7ed03ffad66d196217c4
JWT_EXPIRATION_TIME=1800
Also, automatic backup can be done through yak_server/cli/backup_database
script. It can be run using yak db backup
.
Finally, fastapi needs some configuration to start. Last thing, for development environment, debug needs to be activated with a addditional environment variable:
DEBUG=1
And then start backend with:
uvicorn --reload yak_server:create_fast_api_app --factory
Data initialization
To run local testing, you can use the script create_database.py
, initialize_database.py
and create_admin.py
located in yak_server/cli
folder. To select, set COMPETITION
environment variable in .env
. It will read data from yak_server/data/{COMPETITION}/
.
Testing
To set up test, please add a MySQL database named yak_toto_test
. It will contain all the records created during unit tests. This database is cleaned everytime you run test. That's why a different database is created to avoid deleting records you use for your local testing.
Yak-server is using pytest
to run tests and can run them using poetry run pytest
command into root folder.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for yak_server-0.16.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0eee70c889f43ae7ab1811c0225525f7c4995e85db43829b5c368b1333a5776a |
|
MD5 | 5451d25dc07d431d65dae2ebb5ea0890 |
|
BLAKE2b-256 | 48907167a7962832320f5f82d3c86b90b9c321e46b325136e323e930c8a94030 |