Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions app/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,3 @@
router.include_router(health_router)
router.include_router(echo_router)





@router.get("/")
def root(conn=Depends(get_db_connection)) -> dict:
"""Return a structured welcome message for the API root, including product data."""
cur = conn.cursor()
try:
cur.execute('SELECT id, name, description, price, in_stock, created_at FROM product;')
products = [
{
"id": row[0],
"name": row[1],
"description": row[2],
"price": str(row[3]) if row[3] is not None else None,
"in_stock": row[4],
"created_at": row[5].isoformat() if row[5] else None,
}
for row in cur.fetchall()
]
finally:
cur.close()
epoch = int(time.time() * 1000)
meta = {
"version": __version__,
"time": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),
"epoch": epoch,
"severity": "success",
"message": f"NX AI says hello. Returned {len(products)} products.",
}
return {"meta": meta, "data": products}


@router.get("/health")
def health() -> dict[str, str]:
"""Return the health status of the application."""
return {"status": "ok"}


@router.post("/echo", response_model=EchoResponse)
def echo(body: EchoRequest) -> EchoResponse:
"""Echo the provided message back to the caller."""
return EchoResponse(echo=body.message)
Loading