yak-server


Nameyak-server JSON
Version 0.45.1 PyPI version JSON
download
home_pageNone
SummaryFootball bet rest/graphql server
upload_time2024-11-29 20:31:37
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
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 pip with the following command:

```bash
uv pip install -r requirements.txt
```

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 profile by adding this line in the `.env`

```text
PROFILING=1
```

Be careful, you need to be in debug mode to activate the profiling. In production mode, adding the environment variable will have no impacts.

            

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/5d/b9/2d75b4c86f41384c9b99f9cb67bc918166a42160bf1734990b347f0bf195/yak_server-0.45.1.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 pip with the following command:\n\n```bash\nuv pip install -r requirements.txt\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 profile by adding this line in the `.env`\n\n```text\nPROFILING=1\n```\n\nBe careful, you need to be in debug mode to activate the profiling. In production mode, adding the environment variable will have no impacts.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Football bet rest/graphql server",
    "version": "0.45.1",
    "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": "ba59e5172d1cc527a4351ea6b5ac0a637d51e2fdc1c8ff8a7d756bece926540b",
                "md5": "5673224889d121d8a982efacabdcade7",
                "sha256": "d70518032e24f4df752b62463ddaaa96ac9ee7de5316414983a7be2da28b8fb2"
            },
            "downloads": -1,
            "filename": "yak_server-0.45.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5673224889d121d8a982efacabdcade7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 80072,
            "upload_time": "2024-11-29T20:31:26",
            "upload_time_iso_8601": "2024-11-29T20:31:26.905240Z",
            "url": "https://files.pythonhosted.org/packages/ba/59/e5172d1cc527a4351ea6b5ac0a637d51e2fdc1c8ff8a7d756bece926540b/yak_server-0.45.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5db92d75b4c86f41384c9b99f9cb67bc918166a42160bf1734990b347f0bf195",
                "md5": "cdeb8f6e259ef84102e6daf2542ae847",
                "sha256": "bf21e24b4e73382145149088d42d1488947ff875c2d18d8aae4f8ad407a8ffff"
            },
            "downloads": -1,
            "filename": "yak_server-0.45.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cdeb8f6e259ef84102e6daf2542ae847",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 77409,
            "upload_time": "2024-11-29T20:31:37",
            "upload_time_iso_8601": "2024-11-29T20:31:37.479173Z",
            "url": "https://files.pythonhosted.org/packages/5d/b9/2d75b4c86f41384c9b99f9cb67bc918166a42160bf1734990b347f0bf195/yak_server-0.45.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-29 20:31:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yak-toto",
    "github_project": "yak-server",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "yak-server"
}
        
Elapsed time: 0.39372s