Skip to content

Commit 96fbca0

Browse files
Create services.py
1 parent af3ad6a commit 96fbca0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

aura-core/services.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from fastapi import APIRouter, Depends
2+
from sqlalchemy.future import select
3+
from sqlalchemy.ext.asyncio import AsyncSession
4+
from aura_core.db import get_db
5+
from aura_core.models import Service
6+
7+
router = APIRouter()
8+
9+
@router.post("/register")
10+
async def register_service(name: str, type: str, endpoint: str, db: AsyncSession = Depends(get_db)):
11+
svc = Service(name=name, type=type, endpoint=endpoint, status="active")
12+
db.add(svc)
13+
await db.commit()
14+
return {"msg": "Service registered", "service": {"name": svc.name, "endpoint": svc.endpoint}}
15+
16+
@router.get("/list")
17+
async def list_services(db: AsyncSession = Depends(get_db)):
18+
result = await db.execute(select(Service))
19+
services = result.scalars().all()
20+
return [{"name": s.name, "type": s.type, "endpoint": s.endpoint, "status": s.status} for s in services]

0 commit comments

Comments
 (0)