language models and set defaults are updated
This commit is contained in:
@@ -65,7 +65,9 @@ def setup_exception_handlers(app: FastAPI) -> None:
|
||||
"""
|
||||
custom_exception_handler = HTTPExceptionApiHandler(response_model=JSONResponse)
|
||||
app.add_exception_handler(ValidationError, validation_exception_handler)
|
||||
app.add_exception_handler(HTTPExceptionApi, custom_exception_handler.handle_exception)
|
||||
app.add_exception_handler(
|
||||
HTTPExceptionApi, custom_exception_handler.handle_exception
|
||||
)
|
||||
app.add_exception_handler(Exception, generic_exception_handler)
|
||||
|
||||
|
||||
|
||||
@@ -16,16 +16,6 @@ from Events.Engine.set_defaults.setClusters import (
|
||||
routers: Optional[PrepareRouting] = None
|
||||
|
||||
|
||||
# async def health_check(request: Request):
|
||||
# """Default health check endpoint."""
|
||||
# return {"status": "healthy", "message": "Service is running"}
|
||||
#
|
||||
#
|
||||
# async def ping_test(request: Request, service_name: str = "base-router"):
|
||||
# """Default ping test endpoint."""
|
||||
# return {"ping": "pong", "service": service_name}
|
||||
|
||||
|
||||
def get_all_routers() -> PrepareRouting:
|
||||
"""
|
||||
Get all routers and protected routes from route configurations.
|
||||
@@ -41,3 +31,13 @@ def get_all_routers() -> PrepareRouting:
|
||||
prepare_events = PrepareEvents(cluster_controller_group=cluster_list)
|
||||
SetItems2Redis(prepare_events=prepare_events)
|
||||
return prepare_routing
|
||||
|
||||
|
||||
# async def health_check(request: Request):
|
||||
# """Default health check endpoint."""
|
||||
# return {"status": "healthy", "message": "Service is running"}
|
||||
#
|
||||
#
|
||||
# async def ping_test(request: Request, service_name: str = "base-router"):
|
||||
# """Default ping test endpoint."""
|
||||
# return {"ping": "pong", "service": service_name}
|
||||
|
||||
@@ -12,29 +12,29 @@ RUN apt-get update \
|
||||
# Copy Poetry configuration
|
||||
COPY DockerApiServices/pyproject.toml ./pyproject.toml
|
||||
|
||||
# # Configure Poetry and install dependencies with optimizations
|
||||
# RUN poetry config virtualenvs.create false \
|
||||
# && poetry install --no-interaction --no-ansi --no-root --only main \
|
||||
# && pip cache purge \
|
||||
# && rm -rf ~/.cache/pypoetry
|
||||
# Configure Poetry and install dependencies with optimizations
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --no-interaction --no-ansi --no-root --only main \
|
||||
&& pip cache purge \
|
||||
&& rm -rf ~/.cache/pypoetry
|
||||
|
||||
# # Copy application code
|
||||
# COPY DockerApiServices/EventServiceApi /app
|
||||
# Copy application code
|
||||
COPY DockerApiServices/InitServiceApi /app
|
||||
|
||||
# # Copy application code
|
||||
# COPY ApiLayers /app/ApiLayers
|
||||
# COPY Services /app/Services
|
||||
# Copy application code
|
||||
COPY ApiLayers /app/ApiLayers
|
||||
COPY Services /app/Services
|
||||
|
||||
# # Events
|
||||
# # COPY Events/base_request_model.py /app/Events/base_request_model.py
|
||||
# COPY Events/Engine /app/Events/Engine
|
||||
# COPY Events/AllEvents/events /app/Events/AllEvents/events
|
||||
# COPY DockerApiServices/EventServiceApi/events_file.py /app/Events/AllEvents/events_file.py
|
||||
# Events
|
||||
# COPY Events/base_request_model.py /app/Events/base_request_model.py
|
||||
COPY Events/Engine /app/Events/Engine
|
||||
COPY Events/AllEvents /app/Events/AllEvents
|
||||
COPY Events/base_request_model.py /app/Events/base_request_model.py
|
||||
|
||||
# # Set Python path to include app directory
|
||||
# ENV PYTHONPATH=/app \
|
||||
# PYTHONUNBUFFERED=1 \
|
||||
# PYTHONDONTWRITEBYTECODE=1
|
||||
# Set Python path to include app directory
|
||||
ENV PYTHONPATH=/app \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# # Run the application using the configured uvicorn server
|
||||
# CMD ["poetry", "run", "python", "app.py"]
|
||||
# Run the application using the configured uvicorn server
|
||||
CMD ["poetry", "run", "python", "app.py"]
|
||||
|
||||
5
DockerApiServices/InitServiceApi/app.py
Normal file
5
DockerApiServices/InitServiceApi/app.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from create_all_dependecies import SetRedisDefaults
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
SetRedisDefaults.set_all()
|
||||
71
DockerApiServices/InitServiceApi/config.py
Normal file
71
DockerApiServices/InitServiceApi/config.py
Normal file
@@ -0,0 +1,71 @@
|
||||
class DefaultApiConfig:
|
||||
app: str
|
||||
host: str
|
||||
port: int
|
||||
log_level: str
|
||||
reload: bool
|
||||
|
||||
@classmethod
|
||||
def as_dict(cls):
|
||||
return {
|
||||
"app": cls.app,
|
||||
"host": cls.host,
|
||||
"port": int(cls.port),
|
||||
"log_level": cls.log_level,
|
||||
"reload": bool(cls.reload),
|
||||
}
|
||||
|
||||
|
||||
class ApiStatic:
|
||||
PLACEHOLDER = "https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg"
|
||||
FORGOT_LINK = "https://www.evyos.com.tr/password/create?tokenUrl="
|
||||
BLACKLIST_LINK = "https://www.evyos.com.tr/support/unknown-login-notice/"
|
||||
APP_DIR = "/home/berkay/git-evyos/api-managment-backend/"
|
||||
|
||||
@classmethod
|
||||
def forgot_link(cls, forgot_key):
|
||||
return cls.FORGOT_LINK + forgot_key
|
||||
|
||||
@classmethod
|
||||
def blacklist_login(cls, record_id):
|
||||
return cls.BLACKLIST_LINK + record_id
|
||||
|
||||
|
||||
class HostConfig:
|
||||
MAIN_HOST = "10.10.2.36" # http://10.10.2.36
|
||||
EMAIL_HOST = "10.10.2.34" # http://10.10.2.34
|
||||
|
||||
|
||||
class ApiConfig(DefaultApiConfig):
|
||||
# Application Information
|
||||
APP_NAME = "evyos-auth-api-gateway"
|
||||
TITLE = "WAG API Auth Api Gateway"
|
||||
DESCRIPTION = (
|
||||
"This api is serves as web auth api gateway only to evyos web services."
|
||||
)
|
||||
APP_URL = "https://www.auth.eys.gen.tr"
|
||||
|
||||
# Server Configuration
|
||||
app = "app:app"
|
||||
host = "0.0.0.0"
|
||||
port = 41575
|
||||
log_level = "info"
|
||||
reload = True
|
||||
|
||||
|
||||
class MainConfig:
|
||||
|
||||
# Date and Time Configuration
|
||||
DATETIME_FORMAT = "YYYY-MM-DD HH:mm:ss Z"
|
||||
DATETIME_FORMAT_JS = "YYYY-MM-DD HH:mm:ss +0"
|
||||
|
||||
# Timezone Configuration
|
||||
DEFAULT_TIMEZONE = "GMT+3" # Default timezone for the application
|
||||
SYSTEM_TIMEZONE = "GMT+0" # System timezone (used for internal operations)
|
||||
SUPPORTED_TIMEZONES = ["GMT+0", "GMT+3"] # List of supported timezones
|
||||
|
||||
|
||||
class LanguageConfig:
|
||||
|
||||
SUPPORTED_LANGUAGES = ["en", "tr"]
|
||||
DEFAULT_LANGUAGE = "tr"
|
||||
41
DockerApiServices/InitServiceApi/create_all_dependecies.py
Normal file
41
DockerApiServices/InitServiceApi/create_all_dependecies.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
Route configuration and factory module.
|
||||
Handles dynamic route creation based on configurations.
|
||||
"""
|
||||
|
||||
from Events.Engine.set_defaults.run import get_cluster_controller_group
|
||||
from Events.Engine.set_defaults.setClusters import SetItems2Redis, PrepareEvents
|
||||
|
||||
from ApiLayers.LanguageModels.set_defaults.language_setters import SetClusterLanguageModelsRedis, SetDefaultLanguageModelsRedis
|
||||
from ApiLayers.LanguageModels.Response.all_responses import all_response_list
|
||||
from ApiLayers.LanguageModels.Errors.all_errors import all_errors_list
|
||||
|
||||
|
||||
class SetRedisDefaults:
|
||||
|
||||
@classmethod
|
||||
def set_all(cls) -> None:
|
||||
"""
|
||||
Get all routers and protected routes from route configurations.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
cluster_list = get_cluster_controller_group()
|
||||
default_dict = dict(
|
||||
set_response_languages_list=all_response_list, set_errors_languages_list=all_errors_list,
|
||||
)
|
||||
prepare_events = PrepareEvents(cluster_controller_group=cluster_list)
|
||||
SetItems2Redis(prepare_events=prepare_events)
|
||||
SetDefaultLanguageModelsRedis(**default_dict).set_all()
|
||||
SetClusterLanguageModelsRedis(cluster_controller_group=cluster_list).set_all()
|
||||
|
||||
|
||||
# async def health_check(request: Request):
|
||||
# """Default health check endpoint."""
|
||||
# return {"status": "healthy", "message": "Service is running"}
|
||||
#
|
||||
#
|
||||
# async def ping_test(request: Request, service_name: str = "base-router"):
|
||||
# """Default ping test endpoint."""
|
||||
# return {"ping": "pong", "service": service_name}
|
||||
Reference in New Issue
Block a user