{"id":16868691,"url":"https://github.com/vltr/sanic-boom","last_synced_at":"2025-09-18T17:21:59.452Z","repository":{"id":52312660,"uuid":"148647377","full_name":"vltr/sanic-boom","owner":"vltr","description":"Component injection and caching, faster routing system and non-global middlewares. Give your Sanic application a Boom!","archived":false,"fork":false,"pushed_at":"2022-12-26T20:59:08.000Z","size":99,"stargazers_count":8,"open_issues_count":8,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-02T02:11:44.636Z","etag":null,"topics":["components","lifecycle","productivity","sanic","sanic-framework"],"latest_commit_sha":null,"homepage":"https://sanic-boom.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vltr.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-13T14:09:01.000Z","updated_at":"2023-08-07T18:11:06.000Z","dependencies_parsed_at":"2023-01-31T01:45:31.189Z","dependency_job_id":null,"html_url":"https://github.com/vltr/sanic-boom","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vltr%2Fsanic-boom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vltr%2Fsanic-boom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vltr%2Fsanic-boom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vltr%2Fsanic-boom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vltr","download_url":"https://codeload.github.com/vltr/sanic-boom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244313911,"owners_count":20433013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["components","lifecycle","productivity","sanic","sanic-framework"],"created_at":"2024-10-13T14:59:09.376Z","updated_at":"2025-09-18T17:21:54.382Z","avatar_url":"https://github.com/vltr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==============\n``sanic-boom``\n==============\n\n.. start-badges\n\n.. image:: https://img.shields.io/pypi/status/sanic-boom.svg\n    :alt: PyPI - Status\n    :target: https://pypi.org/project/sanic-boom/\n\n.. image:: https://img.shields.io/pypi/v/sanic-boom.svg\n    :alt: PyPI Package latest release\n    :target: https://pypi.org/project/sanic-boom/\n\n.. image:: https://img.shields.io/pypi/pyversions/sanic-boom.svg\n    :alt: Supported versions\n    :target: https://pypi.org/project/sanic-boom/\n\n.. image:: https://travis-ci.org/vltr/sanic-boom.svg?branch=master\n    :alt: Travis-CI Build Status\n    :target: https://travis-ci.org/vltr/sanic-boom\n\n.. image:: https://readthedocs.org/projects/sanic-boom/badge/?style=flat\n    :target: https://readthedocs.org/projects/sanic-boom\n    :alt: Documentation Status\n\n.. image:: https://codecov.io/github/vltr/sanic-boom/coverage.svg?branch=master\n    :alt: Coverage Status\n    :target: https://codecov.io/github/vltr/sanic-boom\n\n.. image:: https://api.codacy.com/project/badge/Grade/633a45702c6c43a3815ed7199a0be7b2\n    :alt: Codacy Grade\n    :target: https://www.codacy.com/app/vltr/sanic-boom?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=vltr/sanic-boom\u0026amp;utm_campaign=Badge_Grade\n\n.. image:: https://pyup.io/repos/github/vltr/sanic-boom/shield.svg\n    :target: https://pyup.io/account/repos/github/vltr/sanic-boom/\n    :alt: Packages status\n\n.. end-badges\n\nComponents injection, fast routing and non-global (layered) middlewares. Give your Sanic application a Boom!\n\nIn a nutshell\n-------------\n\n.. code-block:: python\n\n    \"\"\"Example code taken from\n    https://marshmallow.readthedocs.io/en/3.0/quickstart.html#quickstart\n    \"\"\"\n\n    import datetime as dt\n    import inspect\n    import typing as t\n\n    from marshmallow import Schema, fields, post_load\n    from sanic.exceptions import ServerError\n    from sanic.response import text\n\n    from sanic_boom import Component, SanicBoom\n\n    # --------------------------------------------------------------------------- #\n    # marshmallow related code\n    # --------------------------------------------------------------------------- #\n\n\n    class User(object):\n        def __init__(self, name, email):\n            self.name = name\n            self.email = email\n            self.created_at = dt.datetime.now()\n\n        def __repr__(self):\n            return \"\u003cUser(name={self.name!r})\u003e\".format(self=self)\n\n        def say_hi(self):\n            return \"hi, my name is {}\".format(self.name)\n\n\n    class UserSchema(Schema):\n        name = fields.Str()\n        email = fields.Email()\n        created_at = fields.DateTime()\n\n        @post_load\n        def make_user(self, data):\n            return User(**data)\n\n\n    # --------------------------------------------------------------------------- #\n    # sanic-boom related code\n    # --------------------------------------------------------------------------- #\n\n\n    class JSONBody(t.Generic[t.T_co]):\n        pass\n\n\n    class JSONBodyComponent(Component):\n        def resolve(self, param: inspect.Parameter) -\u003e bool:\n            if hasattr(param.annotation, \"__origin__\"):\n                return param.annotation.__origin__ == JSONBody\n            return False\n\n        async def get(self, request, param: inspect.Parameter) -\u003e object:\n            inferred_type = param.annotation.__args__[0]\n            try:\n                return inferred_type().load(request.json).data\n            except Exception:\n                raise ServerError(\n                    \"Couldn't convert JSON body to {!s}\".format(inferred_type)\n                )\n\n\n    app = SanicBoom(__name__)\n    app.add_component(JSONBodyComponent)\n\n\n    @app.post(\"/\")\n    async def handler(user: JSONBody[UserSchema]):  # notice the handler parameters\n        return text(user.say_hi())\n\n\n    if __name__ == \"__main__\":\n        app.run(host=\"0.0.0.0\", port=8000, workers=1)\n\n::\n\n    $ curl -v http://localhost:8000/ -d '{\"name\":\"John Doe\",\"email\":\"john.doe@example.tld\"}'\n    *   Trying ::1...\n    * TCP_NODELAY set\n    * connect to ::1 port 8000 failed: Connection refused\n    *   Trying 127.0.0.1...\n    * TCP_NODELAY set\n    * Connected to localhost (127.0.0.1) port 8000 (#0)\n    \u003e POST / HTTP/1.1\n    \u003e Host: localhost:8000\n    \u003e User-Agent: curl/7.61.1\n    \u003e Accept: */*\n    \u003e Content-Length: 50\n    \u003e Content-Type: application/x-www-form-urlencoded\n    \u003e\n    * upload completely sent off: 50 out of 50 bytes\n    \u003c HTTP/1.1 200 OK\n    \u003c Connection: keep-alive\n    \u003c Keep-Alive: 5\n    \u003c Content-Length: 23\n    \u003c Content-Type: text/plain; charset=utf-8\n    \u003c\n    * Connection #0 to host localhost left intact\n    hi, my name is John Doe\n\n.. warning::\n\n    **IMPORTANT**: ``sanic-boom`` is in **very early stages** of development! Use with caution and be aware that some functionalities and APIs may change between versions until they're out of **alpha**.\n\nDependencies\n============\n\n``sanic-boom`` depends on two \"not-so-known\" libraries (both created by the author of ``sanic-boom``):\n\n- `sanic-ipware \u003chttps://github.com/vltr/sanic-ipware\u003e`_; and\n- `xrtr \u003chttps://xrtr.readthedocs.io/en/latest/\u003e`_\n\n.. important::\n\n    Since ``xrtr`` **replaces** the Sanic default router under the hood in ``sanic-boom``, it is very important for the developer to read its documentation (in the link provided above).\n\nDocumentation\n=============\n\nhttps://sanic-boom.readthedocs.io/en/latest/\n\nLicense\n=======\n\n``sanic-boom`` is a free software distributed under the `MIT \u003chttps://choosealicense.com/licenses/mit/\u003e`_ license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvltr%2Fsanic-boom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvltr%2Fsanic-boom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvltr%2Fsanic-boom/lists"}