deez


Namedeez JSON
Version 1.0.4 PyPI version JSON
download
home_page
SummaryA little library to simplify building small APIs on top of API Gateway and Lambda.
upload_time2023-08-23 19:07:38
maintainer
docs_urlNone
authorLemuel Boyce
requires_python>=3.9,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Checks](https://github.com/ProdPerfect/deez/actions/workflows/checks.yml/badge.svg)](https://github.com/ProdPerfect/deez/actions/workflows/checks.yml)
[![PyPI Release](https://github.com/ProdPerfect/deez/actions/workflows/release.yaml/badge.svg)](https://github.com/ProdPerfect/deez/actions/workflows/release.yaml)

# Deez

A little library to simplify building small APIs on top of AWS Lambda and API
Gateway.

> This library is still in development. It is sufficient for ProdPerfect's needs
> but it may not be for yours. Use at your own risk.

## Getting Started

### Requirements

- Python 3.9+
- Blinker 1.4+

### Installation

`pip install deez`

### Creating a resource

Your resource must implement at least one HTTP verb (get, post, put, etc.,)

```python
from deez.resource import Resource
from deez.response import JsonResponse


class MyResource(Resource):
    def get(self, request, *args, **kwargs):
        return JsonResponse(data={'message': 'hello world'})
```

### Example of how to use

`app.py`

````python
from deez import Deez
from deez.resource import Resource
from deez.response import JsonResponse
from deez.urls import path


class HelloWorldView(Resource):
    def get(self, request, *args, **kwargs):
        return JsonResponse(data={'message': 'hello world'})


app = Deez()
app.register_route(path("hello/world", HelloWorldView))

# or you can use regex
app.register_route(r'^hello/world$', HelloWorldView)


`middleware.py`

```python
from deez.middleware import Middleware


class User:
    # fake user object
    pass

class AuthMiddleware(Middleware):
    def before_request(self, request):
        # perhaps you want to authenticate the user and attach it to the request object
        request.user = User() 
        return request
````

`settings.py`

```python
# middleware runs before views are called and before the response is returned
# so you can manipulate the response and requests objects.
MIDDLEWARE = ['middleware.AuthMiddleware']
```

`handler.py`

```python
from app import app

def handle_event(event, context):
    return app.process_request(event, context)
```

### Signals

Deez supports signals. Signals are a way to hook into the request/response
lifecycle. This can be useful for logging metrics or doing other things such as
managing database connections.

```python
from deez.core.signals import request_finished, request_started


@request_started.connect
def my_callback(sender, **kwargs):
    print('request started')


@request_finished.connect
def my_other_callback(sender, **kwargs):
    print('request finished')
```

### Project Structure

See the `examples` directory for a working example.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "deez",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Lemuel Boyce",
    "author_email": "lemuel@prodperfect.com",
    "download_url": "https://files.pythonhosted.org/packages/cc/75/6e12027867117b684c80753854301001d87c328f9d8cd38a918d144cbb13/deez-1.0.4.tar.gz",
    "platform": null,
    "description": "[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Checks](https://github.com/ProdPerfect/deez/actions/workflows/checks.yml/badge.svg)](https://github.com/ProdPerfect/deez/actions/workflows/checks.yml)\n[![PyPI Release](https://github.com/ProdPerfect/deez/actions/workflows/release.yaml/badge.svg)](https://github.com/ProdPerfect/deez/actions/workflows/release.yaml)\n\n# Deez\n\nA little library to simplify building small APIs on top of AWS Lambda and API\nGateway.\n\n> This library is still in development. It is sufficient for ProdPerfect's needs\n> but it may not be for yours. Use at your own risk.\n\n## Getting Started\n\n### Requirements\n\n- Python 3.9+\n- Blinker 1.4+\n\n### Installation\n\n`pip install deez`\n\n### Creating a resource\n\nYour resource must implement at least one HTTP verb (get, post, put, etc.,)\n\n```python\nfrom deez.resource import Resource\nfrom deez.response import JsonResponse\n\n\nclass MyResource(Resource):\n    def get(self, request, *args, **kwargs):\n        return JsonResponse(data={'message': 'hello world'})\n```\n\n### Example of how to use\n\n`app.py`\n\n````python\nfrom deez import Deez\nfrom deez.resource import Resource\nfrom deez.response import JsonResponse\nfrom deez.urls import path\n\n\nclass HelloWorldView(Resource):\n    def get(self, request, *args, **kwargs):\n        return JsonResponse(data={'message': 'hello world'})\n\n\napp = Deez()\napp.register_route(path(\"hello/world\", HelloWorldView))\n\n# or you can use regex\napp.register_route(r'^hello/world$', HelloWorldView)\n\n\n`middleware.py`\n\n```python\nfrom deez.middleware import Middleware\n\n\nclass User:\n    # fake user object\n    pass\n\nclass AuthMiddleware(Middleware):\n    def before_request(self, request):\n        # perhaps you want to authenticate the user and attach it to the request object\n        request.user = User() \n        return request\n````\n\n`settings.py`\n\n```python\n# middleware runs before views are called and before the response is returned\n# so you can manipulate the response and requests objects.\nMIDDLEWARE = ['middleware.AuthMiddleware']\n```\n\n`handler.py`\n\n```python\nfrom app import app\n\ndef handle_event(event, context):\n    return app.process_request(event, context)\n```\n\n### Signals\n\nDeez supports signals. Signals are a way to hook into the request/response\nlifecycle. This can be useful for logging metrics or doing other things such as\nmanaging database connections.\n\n```python\nfrom deez.core.signals import request_finished, request_started\n\n\n@request_started.connect\ndef my_callback(sender, **kwargs):\n    print('request started')\n\n\n@request_finished.connect\ndef my_other_callback(sender, **kwargs):\n    print('request finished')\n```\n\n### Project Structure\n\nSee the `examples` directory for a working example.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A little library to simplify building small APIs on top of API Gateway and Lambda.",
    "version": "1.0.4",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d3e1bb811064ae61b588d1dd8d16131a3042e278099ac4171dd5c39369692739",
                "md5": "59def872f67c877e1a66771e7c93775c",
                "sha256": "f7c434f9b5b218d274265f274b0da81f61ee0e2dba2ed52dedb0f4570fadb9b4"
            },
            "downloads": -1,
            "filename": "deez-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "59def872f67c877e1a66771e7c93775c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 16600,
            "upload_time": "2023-08-23T19:07:37",
            "upload_time_iso_8601": "2023-08-23T19:07:37.147608Z",
            "url": "https://files.pythonhosted.org/packages/d3/e1/bb811064ae61b588d1dd8d16131a3042e278099ac4171dd5c39369692739/deez-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cc756e12027867117b684c80753854301001d87c328f9d8cd38a918d144cbb13",
                "md5": "7bcd3d1a51a6c6016348c7f21005184f",
                "sha256": "991246fee7e645ae44f9583cfb9d883cdd3888135c4d4906b705dc03db6028eb"
            },
            "downloads": -1,
            "filename": "deez-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "7bcd3d1a51a6c6016348c7f21005184f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 11616,
            "upload_time": "2023-08-23T19:07:38",
            "upload_time_iso_8601": "2023-08-23T19:07:38.809076Z",
            "url": "https://files.pythonhosted.org/packages/cc/75/6e12027867117b684c80753854301001d87c328f9d8cd38a918d144cbb13/deez-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-23 19:07:38",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "deez"
}
        
Elapsed time: 0.12255s