Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5691f3133 | ||
|
|
5f80a7a86f | ||
|
|
b588ebcf8a |
5 changed files with 18 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "ohmyapi"
|
name = "ohmyapi"
|
||||||
version = "0.6.0"
|
version = "0.6.2"
|
||||||
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"]
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
__VERSION__ = "0.6.0"
|
__VERSION__ = "0.6.2"
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,6 @@ class Claims(BaseModel):
|
||||||
type: str
|
type: str
|
||||||
sub: str
|
sub: str
|
||||||
user: ClaimsUser
|
user: ClaimsUser
|
||||||
roles: List[str]
|
|
||||||
exp: str
|
exp: str
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -342,9 +342,9 @@ class App:
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
return
|
return
|
||||||
|
|
||||||
getter = getattr(mod, "get", None)
|
installer = getattr(mod, "install", None)
|
||||||
if getter is not None:
|
if installer is not None:
|
||||||
for middleware in getter():
|
for middleware in installer():
|
||||||
self._middlewares.append(middleware)
|
self._middlewares.append(middleware)
|
||||||
|
|
||||||
def __serialize_route(self, route):
|
def __serialize_route(self, route):
|
||||||
|
|
@ -404,10 +404,15 @@ 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(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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),
|
||||||
}),
|
}
|
||||||
]
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue