yak-server


Nameyak-server JSON
Version 0.44.0 PyPI version JSON
download
home_pageNone
SummaryFootball bet rest/graphql server
upload_time2024-04-19 22:55:48
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
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.8",
    "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/5b/f7/1244ee911ae415dff4247f7560bf1b55ffa93aa10c441ae12681d883ff3f/yak_server-0.44.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 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": null,
    "summary": "Football bet rest/graphql server",
    "version": "0.44.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": "4fa6d2f7ff8b73d37011e61a1f9603d5a760d020f16042852c4ab6a0fb0fe7d1",
                "md5": "637e797397a7d2c8fcfaa3b057f9213c",
                "sha256": "0a224dd4dda62f3cb2b28dac662c84223a32ddc061522d3e59c22acf8e01a792"
            },
            "downloads": -1,
            "filename": "yak_server-0.44.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "637e797397a7d2c8fcfaa3b057f9213c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 80591,
            "upload_time": "2024-04-19T22:55:46",
            "upload_time_iso_8601": "2024-04-19T22:55:46.189493Z",
            "url": "https://files.pythonhosted.org/packages/4f/a6/d2f7ff8b73d37011e61a1f9603d5a760d020f16042852c4ab6a0fb0fe7d1/yak_server-0.44.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5bf71244ee911ae415dff4247f7560bf1b55ffa93aa10c441ae12681d883ff3f",
                "md5": "a32dc0912e872440539dc6f01f3124fe",
                "sha256": "3926a5739eff1665221e49e75a46502c648321b4f450cf4dfc34fc6062b3072c"
            },
            "downloads": -1,
            "filename": "yak_server-0.44.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a32dc0912e872440539dc6f01f3124fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 77067,
            "upload_time": "2024-04-19T22:55:48",
            "upload_time_iso_8601": "2024-04-19T22:55:48.095206Z",
            "url": "https://files.pythonhosted.org/packages/5b/f7/1244ee911ae415dff4247f7560bf1b55ffa93aa10c441ae12681d883ff3f/yak_server-0.44.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 22:55:48",
    "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.27137s