diff --git a/app/routes/authentication.py b/app/routes/authentication.py index 2411aff..e050368 100644 --- a/app/routes/authentication.py +++ b/app/routes/authentication.py @@ -1,5 +1,7 @@ from flask import Blueprint, request, jsonify, current_app import requests +from app.extensions import db +from sqlalchemy import text from app.utils.auth import get_headers from app.config import settings from app.utils.logger import logger @@ -12,7 +14,28 @@ BASE_URL = settings.BANK_CALL_BASE_URL @auth_bp.route("/health", methods=["GET"]) def health(): logger.info("Health check endpoint called") - return jsonify({"status": "Up"}) + try: + # Detect database type + dialect = db.engine.dialect.name.lower() + logger.info(f"the database dialect {dialect}") + + if "oracle" in dialect: + query = text("SELECT 1 FROM dual") + else: # Postgres, MySQL, SQLite, etc. + query = text("SELECT 1") + + db.session.execute(query) + return jsonify({ + "status": "success", + "database": dialect, + "message": "Database connection successful" + }), 200 + + except Exception as e: + return jsonify({ + "status": "error", + "message": str(e) + }), 500 @auth_bp.route("/login", methods=["POST"]) diff --git a/app/routes/autocall.py b/app/routes/autocall.py index 05c0ecc..f3ced32 100644 --- a/app/routes/autocall.py +++ b/app/routes/autocall.py @@ -17,6 +17,7 @@ from app.config import settings autocall_bp = Blueprint("autocall", __name__) + @autocall_bp.route("/refresh-verify-disbursement", methods=["GET"]) def verify_transaction(): logger.info(f"Calling VerifyTransaction Components")