feat(api): Finished initial route collection.
This commit is contained in:
23
src/api.py
23
src/api.py
@@ -10,15 +10,25 @@ from utils.auth import key_auth_factory
|
||||
from datamodels import DataModel
|
||||
from constants import DATA_VERSION
|
||||
|
||||
from modules.profiles.data import ProfileData
|
||||
|
||||
from routes.stamps import routes as stamp_routes
|
||||
from routes.documents import routes as doc_routes
|
||||
from routes.lib import dbvar, datamodelsv
|
||||
from routes.users import routes as user_routes
|
||||
from routes.specimens import routes as spec_routes
|
||||
from routes.transactions import routes as txn_routes
|
||||
from routes.events import routes as event_routes
|
||||
from routes.lib import dbvar, datamodelsv, profiledatav
|
||||
|
||||
sys.path.insert(0, os.path.join(os.getcwd()))
|
||||
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# TODO: Move the route table to the __init__ of routes
|
||||
# Maybe we can join route tables together?
|
||||
# Or we just expose an add_routes or register method
|
||||
|
||||
"""
|
||||
- `/stamps` with `POST`, `PUT`, `GET`
|
||||
- `/stamps/{stamp_id}` with `GET`, `PATCH`, `DELETE`
|
||||
@@ -61,8 +71,15 @@ async def attach_db(app: web.Application):
|
||||
datamodel = DataModel()
|
||||
db.load_registry(datamodel)
|
||||
await datamodel.init()
|
||||
|
||||
profiledata = ProfileData()
|
||||
db.load_registry(profiledata)
|
||||
await profiledata.init()
|
||||
|
||||
app[dbvar] = db
|
||||
app[datamodelsv] = datamodel
|
||||
app[profiledatav] = profiledata
|
||||
|
||||
yield
|
||||
|
||||
|
||||
@@ -76,6 +93,10 @@ async def app_factory():
|
||||
app.router.add_get('/', test)
|
||||
app.router.add_routes(stamp_routes)
|
||||
app.router.add_routes(doc_routes)
|
||||
app.router.add_routes(user_routes)
|
||||
app.router.add_routes(spec_routes)
|
||||
app.router.add_routes(event_routes)
|
||||
app.router.add_routes(txn_routes)
|
||||
return app
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user