Compare commits

..

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

4 changed files with 13 additions and 18 deletions

View file

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

View file

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

View file

@ -342,9 +342,9 @@ class App:
except ModuleNotFoundError:
return
installer = getattr(mod, "install", None)
if installer is not None:
for middleware in installer():
getter = getattr(mod, "get", None)
if getter is not None:
for middleware in getter():
self._middlewares.append(middleware)
def __serialize_route(self, route):
@ -404,15 +404,10 @@ class App:
"""
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 {
"models": models,
"models": [
f"{self.name}.{m.__name__}" for m in self._models[f"{self.name}.models"]
],
"middlewares": self.__serialize_middleware(),
"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):
raise ValueError("MIDDLEWARE_CORS must be of type dict")
middleware = (
CORSMiddleware,
{
middleware = [
(CORSMiddleware, {
"allow_origins": CORS_CONFIG.get("ALLOW_ORIGINS", DEFAULT_ORIGINS),
"allow_credentials": CORS_CONFIG.get("ALLOW_CREDENTIALS", DEFAULT_CREDENTIALS),
"allow_methods": CORS_CONFIG.get("ALLOW_METHODS", DEFAULT_METHODS),
"allow_headers": CORS_CONFIG.get("ALLOW_HEADERS", DEFAULT_HEADERS),
}
)
}),
]