Compare commits

...

2 Commits

Author SHA1 Message Date
7f977f90e8 cleanup: Remove MetaModel. 2025-06-10 22:43:08 +10:00
04b6dcbc3f fix: run_app usage 2025-06-10 22:42:51 +10:00
2 changed files with 3 additions and 38 deletions

View File

@@ -86,7 +86,7 @@ async def attach_db(app: web.Application):
async def test(request: web.Request) -> web.Response:
return web.Response(text="Hello World")
async def app_factory():
def app_factory():
auth = key_auth_factory(conf.API['TOKEN'])
app = web.Application(middlewares=[auth])
app.cleanup_ctx.append(attach_db)
@@ -100,11 +100,7 @@ async def app_factory():
return app
async def run_app():
app = await app_factory()
if __name__ == '__main__':
app = app_factory()
web.run_app(app, port=int(conf.API['PORT']))
if __name__ == '__main__':
asyncio.run(run_app())

View File

@@ -16,34 +16,3 @@ class ModelField(NamedTuple):
required: bool
can_create: bool
can_edit: bool
class ModelClassABC[RowT, Payload: TypedDict, CreateParams: TypedDict, EditParams: TypedDict]:
def __init__(self, app: web.Application, row: RowT):
self.app = app
self.data = app[datamodelsv]
self.row = row
@classmethod
async def fetch_from_id(cls, app: web.Application, document_id: int) -> Optional[Self]:
...
@classmethod
async def query(
cls,
**kwargs
) -> List[Self]:
...
@classmethod
async def create(cls, app: web.Application, **kwargs: Unpack[CreateParams]) -> Self:
...
async def prepare(self) -> Payload:
...
async def edit(self, **kwargs: Unpack[EditParams]):
...
async def delete(self) -> Payload:
...