krz/hutch-notify
Notification server for Hutch.
clone: git clone https://gitbay.org/krz/hutch-notify.git
main: app/routers/devices.py · raw
1from fastapi import APIRouter, Depends
2from sqlalchemy.ext.asyncio import AsyncSession
3from app.db import get_db
4from app.schemas import DeviceRegisterIn
5from app.crud import upsert_device
6from app.security import require_api_key
7
8router = APIRouter(prefix="/v1/devices", tags=["devices"], dependencies=[Depends(require_api_key)])
9
10
11@router.post("/register")
12async def register_device(payload: DeviceRegisterIn, db: AsyncSession = Depends(get_db)) -> dict:
13 device = await upsert_device(db, payload)
14 return {
15 "id": device.id,
16 "user_id": device.user_id,
17 "bundle_id": device.bundle_id,
18 "apns_env": device.apns_env,
19 "is_enabled": device.is_enabled,
20 }