diff options
| author | 2024-08-19 01:05:27 +0100 | |
|---|---|---|
| committer | 2024-08-19 01:05:27 +0100 | |
| commit | fe6abd8a5719cbcab1d1207918136f19042e4fa3 (patch) | |
| tree | df09b6c83653189f668fce044c41096386e5bde0 /thallium-backend/src/routes/debug.py | |
| parent | Caddy local support (diff) | |
Add debug endpoints and implement token auth
Co-authored-by: Joe Banks <[email protected]>
Diffstat (limited to 'thallium-backend/src/routes/debug.py')
| -rw-r--r-- | thallium-backend/src/routes/debug.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/thallium-backend/src/routes/debug.py b/thallium-backend/src/routes/debug.py index fac40d7..60c8643 100644 --- a/thallium-backend/src/routes/debug.py +++ b/thallium-backend/src/routes/debug.py @@ -1,10 +1,13 @@ import logging from fastapi import APIRouter +from sqlalchemy import select -from src.settings import PrintfulClient +from src.dto import Voucher +from src.orm import Voucher as DBVoucher +from src.settings import DBSession, PrintfulClient -router = APIRouter(tags=["debug"]) +router = APIRouter(tags=["debug"], prefix="/debug") log = logging.getLogger(__name__) @@ -34,3 +37,13 @@ async def get_v2_oauth_scopes(client: PrintfulClient) -> dict: """Return all templates in printful.""" resp = await client.get("/v2/oauth-scopes") return resp.json() + + [email protected]("/vouchers") +async def get_vouchers(db: DBSession, *, only_active: bool = True) -> list[Voucher]: + """Return all templates in printful.""" + stmt = select(DBVoucher) + if only_active: + stmt = stmt.where(DBVoucher.active) + res = await db.execute(stmt) + return res.scalars().all() |