Name | yak-server JSON |
Version |
0.47.0
JSON |
| download |
home_page | None |
Summary | Football bet rest/graphql server |
upload_time | 2025-01-19 11:10:24 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
api
graphql
mysql
rest
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Yak-toto
[![PyPI](https://img.shields.io/pypi/v/yak-server?label=stable)](https://pypi.org/project/yak-server/)
[![Python Versions](https://img.shields.io/pypi/pyversions/yak-server)](https://pypi.org/project/yak-server/)
[![codecov](https://codecov.io/gh/yak-toto/yak-server/branch/main/graph/badge.svg?token=EZZK5SY5BL)](https://codecov.io/gh/yak-toto/yak-server)
[![🔐 CodeQL](https://github.com/yak-toto/yak-server/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/yak-toto/yak-server/actions/workflows/codeql-analysis.yml)
[![Testing](https://github.com/yak-toto/yak-server/actions/workflows/test.yml/badge.svg)](https://github.com/yak-toto/yak-server/actions/workflows/test.yml)
## 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 automatically loaded.
```text
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 venv python module using the following command:
```bash
uv venv
. .venv/bin/activate
```
Fetch all packages using uv with the following command:
```bash
uv pip install -e .
```
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.
```py
>>> import secrets
>>> secrets.token_hex(16)
'9292f79e10ed7ed03ffad66d196217c4'
```
```text
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 additional environment variable:
```text
DEBUG=1
```
And then start backend with:
```bash
uvicorn --reload yak_server:create_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.
## Profiling
You can run the application with profiler attached. To do so, please run the following command
```bash
uvicorn --reload scripts.profiling:create_app --factory
```
Raw data
{
"_id": null,
"home_page": null,
"name": "yak-server",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "api, graphql, mysql, rest",
"author": null,
"author_email": "Guillaume Le Pape <gui.lepape25@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8e/3b/35e6daf2ad460dcc975dfa3b9de3b089f5494f9026d68cd7656d091dee31/yak_server-0.47.0.tar.gz",
"platform": null,
"description": "# Yak-toto\n\n[![PyPI](https://img.shields.io/pypi/v/yak-server?label=stable)](https://pypi.org/project/yak-server/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/yak-server)](https://pypi.org/project/yak-server/)\n[![codecov](https://codecov.io/gh/yak-toto/yak-server/branch/main/graph/badge.svg?token=EZZK5SY5BL)](https://codecov.io/gh/yak-toto/yak-server)\n[![\ud83d\udd10 CodeQL](https://github.com/yak-toto/yak-server/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/yak-toto/yak-server/actions/workflows/codeql-analysis.yml)\n[![Testing](https://github.com/yak-toto/yak-server/actions/workflows/test.yml/badge.svg)](https://github.com/yak-toto/yak-server/actions/workflows/test.yml)\n\n## Requisites\n\n- Ubuntu 22.04\n- MySQL 8.0.30\n\n## How to build the project\n\n### Database\n\nInstall 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 automatically loaded.\n\n```text\nMYSQL_USER_NAME=my_user_name\nMYSQL_PASSWORD=my_password\nMYSQL_DB=my_database_name\n```\n\nYou can also set MySQL port by adding `MYSQL_PORT=my_port` to `.env` file. If not set, it will be 3306 by default.\n\n### Backend\n\nRun your project in a Python env is highly recommend. You can use venv python module using the following command:\n\n```bash\nuv venv\n. .venv/bin/activate\n```\n\nFetch all packages using uv with the following command:\n\n```bash\nuv pip install -e .\n```\n\nBefore starting the backend, add `JWT_SECRET_KEY` and `JWT_EXPIRATION_TIME` in `.env` same as the MySQL user name and password. As\nlogin 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.\n\n```py\n>>> import secrets\n>>> secrets.token_hex(16)\n'9292f79e10ed7ed03ffad66d196217c4'\n```\n\n```text\nJWT_SECRET_KEY=9292f79e10ed7ed03ffad66d196217c4\nJWT_EXPIRATION_TIME=1800\n```\n\nAlso, automatic backup can be done through `yak_server/cli/backup_database` script. It can be run using `yak db backup`.\n\nFinally, fastapi needs some configuration to start. Last thing, for development environment, debug needs to be activated with a additional environment variable:\n\n```text\nDEBUG=1\n```\n\nAnd then start backend with:\n\n```bash\nuvicorn --reload yak_server:create_app --factory\n```\n\n### Data initialization\n\nTo 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}/`.\n\n### Testing\n\nTo 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.\n\nYak-server is using `pytest` to run tests.\n\n## Profiling\n\nYou can run the application with profiler attached. To do so, please run the following command\n\n```bash\nuvicorn --reload scripts.profiling:create_app --factory\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Football bet rest/graphql server",
"version": "0.47.0",
"project_urls": {
"Homepage": "https://github.com/yak-toto/yak-server",
"Repository": "https://github.com/yak-toto/yak-server"
},
"split_keywords": [
"api",
" graphql",
" mysql",
" rest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a8edd69403c3ee4a38c3ce7cb92e991c857018b27a2214d3b03e60ac245a95ed",
"md5": "80aac754ffdf801ffae8a953589d2b34",
"sha256": "dd85dad55fb55eae5dad755a5e2b0cd14ac4ea75ac417598359e5b66e656ed1e"
},
"downloads": -1,
"filename": "yak_server-0.47.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "80aac754ffdf801ffae8a953589d2b34",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 79163,
"upload_time": "2025-01-19T11:10:21",
"upload_time_iso_8601": "2025-01-19T11:10:21.802984Z",
"url": "https://files.pythonhosted.org/packages/a8/ed/d69403c3ee4a38c3ce7cb92e991c857018b27a2214d3b03e60ac245a95ed/yak_server-0.47.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8e3b35e6daf2ad460dcc975dfa3b9de3b089f5494f9026d68cd7656d091dee31",
"md5": "7f69c322290545d2da5081e278711630",
"sha256": "c34d4b10d06182ec793edac75e47833be89e4b790deaed1335c6c4ea05bd83bc"
},
"downloads": -1,
"filename": "yak_server-0.47.0.tar.gz",
"has_sig": false,
"md5_digest": "7f69c322290545d2da5081e278711630",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 162067,
"upload_time": "2025-01-19T11:10:24",
"upload_time_iso_8601": "2025-01-19T11:10:24.007654Z",
"url": "https://files.pythonhosted.org/packages/8e/3b/35e6daf2ad460dcc975dfa3b9de3b089f5494f9026d68cd7656d091dee31/yak_server-0.47.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-19 11:10:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yak-toto",
"github_project": "yak-server",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "yak-server"
}