Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fastapi-injectable to utils section #186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JasperSui
Copy link

@JasperSui JasperSui commented Dec 20, 2024

Hi mjhea0,

fastapi-injectable is a production-ready package for FastAPI developers who need to use dependency injection outside of HTTP routes, which solves the problem that exists in FastAPI ecosystem for a long time.

Basic example here:

from typing import Annotated

from fastapi import Depends
from fastapi_injectable import injectable

class Database:
    def query(self) -> str:
        return "data"

def get_db() -> Database:
    return Database()

@injectable
def process_data(db: Annotated[Database, Depends(get_db)]) -> str:
    return db.query()

# Use it anywhere!
result = process_data()
print(result) # Output: 'data'

Here's the related issue and discussion:

I understand that you said:

I tend to only add projects that are at least a year old and are consistently being updated.

But I genuinely think fastapi-injectable will help lots of devs if this can be put on the list as soon as possible, but this is your project, so the decision is ultimately yours to make.

Anyways, thanks for this "awesome" repository!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant