-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
63 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
from fastapi import APIRouter | ||
from odmantic import AIOEngine | ||
|
||
from core.tag import get_all_tags | ||
from schemas.tag import TagsResponse | ||
from settings import EngineD | ||
from settings import Engine | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/tags", response_model=TagsResponse) | ||
async def get_tags(engine: AIOEngine = EngineD): | ||
tags = await get_all_tags(engine) | ||
async def get_tags(): | ||
tags = await get_all_tags(Engine) | ||
return TagsResponse(tags=tags) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
from typing import Optional | ||
|
||
from odmantic.fastapi import AIOEngineDependency | ||
from pydantic import BaseSettings | ||
from motor.motor_asyncio import AsyncIOMotorClient | ||
from odmantic import AIOEngine | ||
from pydantic import Field | ||
from pydantic.types import SecretStr | ||
from pydantic_settings import BaseSettings | ||
|
||
|
||
class _Settings(BaseSettings): | ||
SECRET_KEY: SecretStr = ( | ||
SECRET_KEY: SecretStr = Field( | ||
"09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7" | ||
) | ||
ALGORITHM = "HS256" | ||
ACCESS_TOKEN_EXPIRE_MINUTES = 30 | ||
ALGORITHM: str = "HS256" | ||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 | ||
MONGO_URI: Optional[str] = None | ||
|
||
|
||
# Make this a singleton to avoid reloading it from the env everytime | ||
SETTINGS = _Settings() | ||
|
||
EngineD = AIOEngineDependency(mongo_uri=SETTINGS.MONGO_URI) | ||
MotorClient = AsyncIOMotorClient(SETTINGS.MONGO_URI) | ||
Engine = AIOEngine(MotorClient, database="test") |
Oops, something went wrong.