feat(Global): Add health check api

This commit is contained in:
Luka Radenovic 2021-11-16 12:04:40 +01:00
parent 2b2de0123a
commit 0bd9434d12
2 changed files with 10 additions and 4 deletions

View file

@ -1,3 +1,9 @@
from flask import Blueprint
api_v1 = Blueprint('api_v1', __name__, url_prefix='/api/v1')
api_v1 = Blueprint("api_v1", __name__, url_prefix="/api/v1")
@api_v1.route("/")
@api_v1.route("/health")
def api_index():
return "Open App Stack API v1.0"

View file

@ -12,7 +12,7 @@ class BadRequest(Exception):
def bad_request_error(e):
message = e.args[0] if e.args else "Bad request to the server."
return jsonify({"errorMessage": message})
return jsonify({"errorMessage": message}), 400
def validation_error(e):
@ -24,11 +24,11 @@ def validation_error(e):
def kratos_error(e):
message = e.args[0] if e.args else "Failed to contant Kratos."
message = e.args[0] if e.args else "Failed to contact Kratos."
status_code = e.args[1] if e.args else 500
return jsonify({"errorMessage": message}), status_code
def global_error(e):
message = e.args[0] if e.args else "Something went wrong."
message = str(e)
return jsonify({"errorMessage": message})