diff --git a/app/api/routes/routes.py b/app/api/routes/routes.py index 47e4186..1cd4120 100644 --- a/app/api/routes/routes.py +++ b/app/api/routes/routes.py @@ -1,4 +1,5 @@ from flask import Flask, Blueprint, request, jsonify, send_from_directory +import sys import os from app.api.services import ( RACCheckService, @@ -16,6 +17,7 @@ from app.utils.logger import logger from app.api.middlewares import require_api_key, require_app_id, enforce_json + api = Blueprint("api", __name__) @@ -162,7 +164,34 @@ def new_transaction_check(): response = NewTransactionCheckService.process_request(data) return response + # Health Check Endpoint -@api.route('/health', methods=['GET']) +@api.route('/system-health-check', methods=['GET']) def health_check(): - return {"status": "ok"} , 200 \ No newline at end of file + """Basic system health check""" + try: + checks = { + "python_version": sys.version_info >= (3, 6), + "disk_space": os.statvfs('/').f_bavail * os.statvfs('/').f_frsize > 500 * 1024 * 1024, + "system_operational": True + } + + if all(checks.values()): + return jsonify({ + "status": "Active", + "responseCode": "00", + "responseMessage": "Successful" + }), 200 + else: + return jsonify({ + "status": "Degraded", + "responseCode": "01", + "responseMessage": "System check failed" + }), 200 + + except Exception as e: + return jsonify({ + "status": "Error", + "responseCode": "99", + "responseMessage": f"Health check failed: {str(e)}" + }), 500 diff --git a/app/swagger/digifi_swagger.json b/app/swagger/digifi_swagger.json index d769dd3..c9f9524 100644 --- a/app/swagger/digifi_swagger.json +++ b/app/swagger/digifi_swagger.json @@ -110,6 +110,9 @@ } ], "paths": { + "/api/system-health-check": { + "$ref": "swagger/paths/HealthCheck.json" + }, "/api/rac-check": { "$ref": "swagger/paths/RACCheck.json" }, diff --git a/app/swagger/paths/HealthCheck.json b/app/swagger/paths/HealthCheck.json new file mode 100644 index 0000000..01207ac --- /dev/null +++ b/app/swagger/paths/HealthCheck.json @@ -0,0 +1,19 @@ +{ + "get": { + "tags": ["System"], + "summary": "System Health Check", + "description": "Returns the current health status of the system", + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "../schemas/HealthCheckResponse.json" + } + } + } + } + } + } + } \ No newline at end of file diff --git a/app/swagger/schemas/HealthCheckRequest.json b/app/swagger/schemas/HealthCheckRequest.json new file mode 100644 index 0000000..3824297 --- /dev/null +++ b/app/swagger/schemas/HealthCheckRequest.json @@ -0,0 +1,17 @@ +{ + "type": "object", + "properties": { + "status": { + "type": "string", + "example": "Active" + }, + "responseCode": { + "type": "string", + "example": "00" + }, + "responseMessage": { + "type": "string", + "example": "Successful" + } + } +} \ No newline at end of file diff --git a/app/swagger/schemas/HealthCheckResponse.json b/app/swagger/schemas/HealthCheckResponse.json new file mode 100644 index 0000000..3824297 --- /dev/null +++ b/app/swagger/schemas/HealthCheckResponse.json @@ -0,0 +1,17 @@ +{ + "type": "object", + "properties": { + "status": { + "type": "string", + "example": "Active" + }, + "responseCode": { + "type": "string", + "example": "00" + }, + "responseMessage": { + "type": "string", + "example": "Successful" + } + } +} \ No newline at end of file