Metadata-Version: 2.1
Name: joey
Version: 0.4.0
Summary: Async web framework on top of fastapi and orm
Home-page: https://github.com/pinecrew/joey
Author: pinecrew
License: UNKNOWN
Keywords: joey web framework orm fastapi
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.8, <4
Description-Content-Type: text/markdown
Requires-Dist: alembic (==1.4.2)
Requires-Dist: fastapi (==0.61.0)
Requires-Dist: orm (==0.1.5)
Requires-Dist: pytz (==2020.1)
Requires-Dist: mako (==1.1.3)
Requires-Dist: click (==7.1.2)
Requires-Dist: pyyaml (==5.3.1)
Provides-Extra: dev
Requires-Dist: black (==19.10b0) ; extra == 'dev'
Requires-Dist: pylint ; extra == 'dev'
Provides-Extra: sessions
Requires-Dist: pyjwt (==1.7.1) ; extra == 'sessions'
Requires-Dist: cryptography (==3.0) ; extra == 'sessions'

# joey

[![](https://img.shields.io/pypi/v/joey.svg)](https://pypi.org/project/joey/)
[![](https://img.shields.io/pypi/l/joey.svg)](https://github.com/pinecrew/joey/blob/master/LICENSE)

Async web framework on top of [fastapi](https://pypi.org/project/fastapi/) and [orm](https://pypi.org/project/orm/)

# How to start
Let's create demo project
```sh
$ mkdir demo-project
$ cd demo-project
$ pipenv install joey
$ pipenv shell
$ joey init 
```

Joey will create the following project structure
```sh
.
├── alembic.ini
├── asgi.py
├── migrations
│   ├── env.py
│   ├── script.py.mako
│   └── versions
└── settings
    ├── common.py
    ├── common.yml
    ├── development.py
    └── __init__.py
```

Let's add the application to the given project structure
```sh
$ joey add hello
# or with autoregister parameter
$ joey add -a hello
```

Joey will add the following files in a separate folder
```sh
.
└── hello
    ├── __init__.py
    ├── models.py
    └── routes.py
```

If you use `-a` flag then **joey** automatic register your app and route in project settings file
```yaml
APPLICATIONS:
- hello
ROUTES:
  hello:
    prefix: /hello
    tags:
    - hello
```
otherwise manually edit `settings/common.yml` file.

Now implement model in file  `hello/models.py`
```py
class Item(Model):
    id = orm.Integer(primary_key=True)
    text = orm.Text()
```

Implement a simple route in `hello/routes.py`, than can access to database
```py
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel


from hello.models import Item as ItemDB


class Item(BaseModel):
    text: str


router = APIRouter()

@router.post('/{id}', response_model=Item)
async def item(id: int) -> Item:
    try:
        return await ItemDB.objects.get(id=id)
    except ItemDB.DoesNotExist:
        raise HTTPException(status_code=404, detail='Item not found')
```


Next step - create a database, then migrate it and add a couple of elements
```sh
$ joey revise 'init database'
$ joey migrate
$ sqlite3 db.sqlite "insert into items (text) values ('hello'), ('joe here');"
```

Everything is ready, now you can start with uvicorn
```sh
$ joey run
# or
$ uvicorn asgi:app --reload
```

And request data with Swagger UI by `http://localhost:8000/docs`.


