From 806c25d7b070ebe4b8b65abacc387bedebc72e79 Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Tue, 26 May 2026 14:59:41 +0200 Subject: [PATCH] fix profile link api --- mih_api_hub/main.py | 46 +++++++----------------- mih_api_hub/mih_database/mihDbObjects.py | 22 ++++++++++-- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/mih_api_hub/main.py b/mih_api_hub/main.py index 1d414250..5c8cf1ae 100644 --- a/mih_api_hub/main.py +++ b/mih_api_hub/main.py @@ -1,6 +1,6 @@ -from fastapi import FastAPI, Depends, HTTPException -from pydantic import BaseModel -# from .routers import docOffices, patients, patients_files, patients_notes, users, fileStorage, medicine +from fastapi import FastAPI, Request +from fastapi.responses import JSONResponse + import routers.docOffices as docOffices import routers.appointments as appointments import routers.patients as patients @@ -21,18 +21,13 @@ import routers.mzansi_directory as mzansi_directory import routers.user_consent as user_consent import routers.icd10_codes as icd10_codes import routers.mine_sweeper_leaderboard as mine_sweeper_leaderboard +import routers.profile_links as profile_links from fastapi.middleware.cors import CORSMiddleware -from fastapi.middleware import Middleware from supertokens_python import get_all_cors_headers from supertokens_python.framework.fastapi import get_middleware from supertokens_python import init, InputAppInfo, SupertokensConfig -from supertokens_python.recipe import emailpassword, session, dashboard, emailverification - - -from supertokens_python.recipe.session.framework.fastapi import verify_session -from supertokens_python.recipe.emailverification import EmailVerificationClaim -from supertokens_python.recipe.session import SessionContainer +from supertokens_python.recipe import emailpassword, session, dashboard import os from dotenv import load_dotenv @@ -109,33 +104,18 @@ app.include_router(user_consent.router) app.include_router(icd10_codes.router) app.include_router(appointments.router) app.include_router(mine_sweeper_leaderboard.router) +app.include_router(profile_links.router) # Check if server is up @app.get("/", tags=["Server Check"]) def check_server(): - return serverRunning() - -# # Check if server is up -# @app.get("/session") -# def read_root(): -# async def like_comment(session: SessionContainer = Depends(verify_session())): -# user_id = session.get_user_id() - -# return {"Session id": user_id} - -# @app.post('/get_user_info_api') -# async def get_user_info_api(session: SessionContainer = Depends(verify_session())): -# user_id = session.get_user_id() - -# thirdparty_user = await get_user_by_id_thirdparty(user_id) -# if thirdparty_user is None: -# passwordless_user = await get_user_by_id_passwordless(user_id) -# if passwordless_user is not None: -# print(passwordless_user) -# else: -# print(thirdparty_user) - -def serverRunning(): return {"Status": "Server is Up and Running. whats good in the hood"} +@app.exception_handler(Exception) +async def global_exception_handler(request: Request, exc: Exception): + print(f"Global Error Log: {exc}") + return JSONResponse( + status_code=500, + content={"detail": "An internal server error occurred."}, + ) diff --git a/mih_api_hub/mih_database/mihDbObjects.py b/mih_api_hub/mih_database/mihDbObjects.py index dc888bb0..3149e3d9 100644 --- a/mih_api_hub/mih_database/mihDbObjects.py +++ b/mih_api_hub/mih_database/mihDbObjects.py @@ -1,5 +1,5 @@ from sqlalchemy import DateTime, Column, Integer, String, DECIMAL, text -from sqlalchemy.orm import declarative_base +from sqlalchemy.orm import declarative_base, Mapped, mapped_column Base = declarative_base() class User(Base): @@ -118,4 +118,22 @@ class MineSweeperLeaderboard(Base): f"game_time='{self.game_time}', " f"game_score='{self.game_score}' " f"played_date='{self.played_date}')>" - ) \ No newline at end of file + ) + +class ProfileLink(Base): + __tablename__ = 'profile_links' + __table_args__ = {'schema': 'app_data'} + idprofile_links: Mapped[int] = mapped_column(Integer, primary_key=True) + app_id: Mapped[str] = mapped_column(String(128), nullable=False, unique=True) + site_name: Mapped[str] = mapped_column(String(128), nullable=False) + custom_name: Mapped[str] = mapped_column(String(128), nullable=False) + destination: Mapped[str] = mapped_column(String(512), nullable=False) + business_id: Mapped[str] = mapped_column(String(128), nullable=False) + order: Mapped[int] = mapped_column(Integer, nullable=False) + + def __repr__(self): + return ( + f"" + )