{"id":17658834,"url":"https://github.com/volfpeter/fasted","last_synced_at":"2026-04-12T07:32:36.882Z","repository":{"id":232033793,"uuid":"783211260","full_name":"volfpeter/fasted","owner":"volfpeter","description":"FastAPI dependencies and utilities.","archived":false,"fork":false,"pushed_at":"2024-04-12T20:28:41.000Z","size":612,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T00:46:12.693Z","etag":null,"topics":["fastapi","python","utility"],"latest_commit_sha":null,"homepage":"https://volfpeter.github.io/fasted/","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/volfpeter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-07T08:44:47.000Z","updated_at":"2024-10-26T08:03:34.000Z","dependencies_parsed_at":"2024-04-12T21:37:11.035Z","dependency_job_id":null,"html_url":"https://github.com/volfpeter/fasted","commit_stats":null,"previous_names":["volfpeter/fasted"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volfpeter%2Ffasted","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volfpeter%2Ffasted/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volfpeter%2Ffasted/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volfpeter%2Ffasted/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/volfpeter","download_url":"https://codeload.github.com/volfpeter/fasted/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246306726,"owners_count":20756358,"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":["fastapi","python","utility"],"created_at":"2024-10-23T15:43:26.273Z","updated_at":"2025-10-24T08:45:25.129Z","avatar_url":"https://github.com/volfpeter.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Tests](https://github.com/volfpeter/fasted/actions/workflows/tests.yml/badge.svg)\n![Linters](https://github.com/volfpeter/fasted/actions/workflows/linters.yml/badge.svg)\n![Documentation](https://github.com/volfpeter/fasted/actions/workflows/build-docs.yml/badge.svg)\n![PyPI package](https://img.shields.io/pypi/v/fasted?color=%2334D058\u0026label=PyPI%20Package)\n\n**Source code**: [https://github.com/volfpeter/fasted](https://github.com/volfpeter/fasted)\n\n**Documentation and examples**: [https://volfpeter.github.io/fasted](https://volfpeter.github.io/fasted/)\n\n# FastED\n\nFastAPI dependencies and utilities.\n\n## Installation\n\nThe package is available on PyPI and can be installed with:\n\n```console\n$ pip install fasted\n```\n\n## Features\n\n### `selfdependent`\n\nDecorator that let's you use your business objects' instance methods as FastAPI dependencies without writing any additional code.\n\nSupports:\n\n- **Sync and async** instance **methods**.\n- **Sync and async generator** methods.\n- **Inheritence** and **`super()`** calls is decorated methods.\n- An **optional factory** (FastAPI dependency) for creating the `self` instance. If not set, the class' `__init__()` method will serve as the dependency for creating the `self` instance.\n- **Decorated** instance **methods will behave as expected** if called directly.\n\nExample use:\n\n```python\nfrom typing import Annotated\n\nfrom fastapi import Depends, FastAPI\nfrom fasted import selfdependent\n\n\ndef double() -\u003e \"Multiplier\":\n    # Dependency that returns a Multiplier with base = 2.\n    return Multiplier(2)\n\n\nclass Multiplier:\n    def __init__(self, base: float) -\u003e None:\n        self.base = base\n\n    @selfdependent()\n    def multiply(self, mul: float) -\u003e float:\n        # `__init__()` will be used as the dependency to create `self`, so the route\n        # where this method is used will have a `base` and a `mul` query parameter.\n        return self.base * mul\n\n    @selfdependent(factory=double)\n    async def double(self, mul: float) -\u003e float:\n        # `double()` will be used as the dependency to create `self`, so the route\n        # where this method is used will only have a `mul` query parameter.\n        return self.base * mul\n\n\napp = FastAPI()\n\n\n@app.get(\"/multiply\")\ndef multiply_route(value: Annotated[float, Depends(Multiplier.multiply)]) -\u003e float:\n    # FastAPI will create the `Multiplier` instance based on `Multiplier.__init__()` and\n    # automatically feed this `instance` as `self` to `Multiplier.multiply()` to calculate\n    # the value of the dependency.\n    return value\n\n\n@app.get(\"/double\")\ndef double_route(value: Annotated[float, Depends(Multiplier.double)]) -\u003e float:\n    # FastAPI will create the `Multiplier` instance using the `double()` factory (dependency)\n    # and automatically feed this instance as `self` to `Multiplier.multiply()` to\n    # calculate the value of the dependency.\n    return value\n```\n\n### `Dependency`\n\nGeneric type for FastAPI dependencies.\n\nExample use:\n\n```python\nfrom typing import Annotated, Generator\n\nfrom fastapi import FastAPI, APIRouter\nfrom fasted import Dependency\n# from x import Session\n\n\ndef make_api(make_session: Dependency[Session]) -\u003e APIRouter:\n    DependsSession = Annotated[Session, Depends(make_session)]\n\n    api = APIRouter()\n\n    @api.get(\"/\")\n    def get(session: DependsSession) -\u003e int:\n        return 4\n\n    return api\n\n\ndef make_db_session() -\u003e Generator[Session, None, None]:\n    with Session(database) as session:\n        yield session\n\n\napp = FastAPI()\napp.include_router(make_api(make_db_session), prefix=\"/random-number\")\n```\n\n## Dependencies\n\nBeing a FastAPI utility library, the only dependency is (and will remain) `fastapi`.\n\n## Development\n\nUse `ruff` for linting and formatting, `mypy` for static code analysis, and `pytest` for testing.\n\nThe documentation is built with `mkdocs-material` and `mkdocstrings`.\n\n## Contributing\n\nAll contributions are welcome.\n\n## License - MIT\n\nThe package is open-sourced under the conditions of the [MIT license](https://choosealicense.com/licenses/mit/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolfpeter%2Ffasted","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvolfpeter%2Ffasted","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolfpeter%2Ffasted/lists"}