added health checks #47
@@ -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"])
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user