Compare commits
2 Commits
c07577cc0a
...
7f977f90e8
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f977f90e8 | |||
| 04b6dcbc3f |
10
src/api.py
10
src/api.py
@@ -86,7 +86,7 @@ async def attach_db(app: web.Application):
|
|||||||
async def test(request: web.Request) -> web.Response:
|
async def test(request: web.Request) -> web.Response:
|
||||||
return web.Response(text="Hello World")
|
return web.Response(text="Hello World")
|
||||||
|
|
||||||
async def app_factory():
|
def app_factory():
|
||||||
auth = key_auth_factory(conf.API['TOKEN'])
|
auth = key_auth_factory(conf.API['TOKEN'])
|
||||||
app = web.Application(middlewares=[auth])
|
app = web.Application(middlewares=[auth])
|
||||||
app.cleanup_ctx.append(attach_db)
|
app.cleanup_ctx.append(attach_db)
|
||||||
@@ -100,11 +100,7 @@ async def app_factory():
|
|||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
async def run_app():
|
if __name__ == '__main__':
|
||||||
app = await app_factory()
|
app = app_factory()
|
||||||
web.run_app(app, port=int(conf.API['PORT']))
|
web.run_app(app, port=int(conf.API['PORT']))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
asyncio.run(run_app())
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,34 +16,3 @@ class ModelField(NamedTuple):
|
|||||||
required: bool
|
required: bool
|
||||||
can_create: bool
|
can_create: bool
|
||||||
can_edit: 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:
|
|
||||||
...
|
|
||||||
|
|||||||
Reference in New Issue
Block a user