Compare commits

..

No commits in common. "main" and "0.6.0" have entirely different histories.
main ... 0.6.0

5 changed files with 14 additions and 18 deletions

View file

@ -1,6 +1,6 @@
[project] [project]
name = "ohmyapi" name = "ohmyapi"
version = "0.6.2" version = "0.6.0"
description = "Django-flavored scaffolding and management layer around FastAPI, Pydantic, TortoiseORM and Aerich migrations" description = "Django-flavored scaffolding and management layer around FastAPI, Pydantic, TortoiseORM and Aerich migrations"
license = "MIT" license = "MIT"
keywords = ["fastapi", "tortoise", "orm", "pydantic", "async", "web-framework"] keywords = ["fastapi", "tortoise", "orm", "pydantic", "async", "web-framework"]

View file

@ -1 +1 @@
__VERSION__ = "0.6.2" __VERSION__ = "0.6.0"

View file

@ -53,6 +53,7 @@ class Claims(BaseModel):
type: str type: str
sub: str sub: str
user: ClaimsUser user: ClaimsUser
roles: List[str]
exp: str exp: str

View file

@ -342,9 +342,9 @@ class App:
except ModuleNotFoundError: except ModuleNotFoundError:
return return
installer = getattr(mod, "install", None) getter = getattr(mod, "get", None)
if installer is not None: if getter is not None:
for middleware in installer(): for middleware in getter():
self._middlewares.append(middleware) self._middlewares.append(middleware)
def __serialize_route(self, route): def __serialize_route(self, route):
@ -404,15 +404,10 @@ class App:
""" """
Convenience method for serializing the runtime data. Convenience method for serializing the runtime data.
""" """
# An app may come without any models
models = []
if f"{self.name}.models" in self._models:
models = [
f"{self.name}.{m.__name__}"
for m in self._models[f"{self.name}.models"]
]
return { return {
"models": models, "models": [
f"{self.name}.{m.__name__}" for m in self._models[f"{self.name}.models"]
],
"middlewares": self.__serialize_middleware(), "middlewares": self.__serialize_middleware(),
"routes": self.__serialize_router(), "routes": self.__serialize_router(),
} }

View file

@ -15,12 +15,12 @@ CORS_CONFIG: Dict[str, Any] = getattr(settings, "MIDDLEWARE_CORS", {})
if not isinstance(CORS_CONFIG, dict): if not isinstance(CORS_CONFIG, dict):
raise ValueError("MIDDLEWARE_CORS must be of type dict") raise ValueError("MIDDLEWARE_CORS must be of type dict")
middleware = ( middleware = [
CORSMiddleware, (CORSMiddleware, {
{
"allow_origins": CORS_CONFIG.get("ALLOW_ORIGINS", DEFAULT_ORIGINS), "allow_origins": CORS_CONFIG.get("ALLOW_ORIGINS", DEFAULT_ORIGINS),
"allow_credentials": CORS_CONFIG.get("ALLOW_CREDENTIALS", DEFAULT_CREDENTIALS), "allow_credentials": CORS_CONFIG.get("ALLOW_CREDENTIALS", DEFAULT_CREDENTIALS),
"allow_methods": CORS_CONFIG.get("ALLOW_METHODS", DEFAULT_METHODS), "allow_methods": CORS_CONFIG.get("ALLOW_METHODS", DEFAULT_METHODS),
"allow_headers": CORS_CONFIG.get("ALLOW_HEADERS", DEFAULT_HEADERS), "allow_headers": CORS_CONFIG.get("ALLOW_HEADERS", DEFAULT_HEADERS),
} }),
) ]