
    ##i              	          d Z ddlZddlmZ ddlmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZmZmZ ddlmZ ddlm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z&  ejN                   e(eejR                        d        ejT                  d      jW                  ejX                          ejT                  e-      Z.	  e         ej^                  d       	 ddl3m4Z4 e.j_                  d       edefd       Z7 eejp                  dejr                  ejt                  dde7       Z;ejx                  Z=dZ>ej~                  d!k(  rd"Z>nej~                  d#k(  rd$Z>e;j                  e
e=e>d%ej                  ej                  &       e;j                  d'      d(efd)       ZDe;j                  e$       e;j                  e        e;j                  ee       e;j                  ee       e;j                  ee       e;j                  e0e        ee;        e&        e;j                  d* eej                  +      d,-       e-d.k(  rRddlHZH eHj                  d/ej                  ej                  ejt                  ejR                  j                         0       yy# e0$ rZ1 ejd                  de1         dZ1[1ww xY w# e5$ r dZ4e.jm                  d       Y w xY w)1z!
FastAPI Application Entry Point
    N)Path)asynccontextmanager)FastAPIRequest)CORSMiddleware)StaticFiles)HTTPExceptionRequestValidationError)BaseHTTPMiddleware)settings)include_routers)register_models)api_exception_handlerhttp_exception_handlervalidation_error_handlergeneral_exception_handler)APIException)LoggingMiddleware)SecurityMiddleware)CommonResponseMiddleware)create_uploads_directoryz4%(asctime)s - %(name)s - %(levelname)s - %(message)s)levelformatzsqlalchemy.enginez'Database models registered successfullyz#Error registering database models: )
celery_appzCelery integration initializedz8Celery not available - background tasks will be disabledappc                  K   t         j                  d       t         j                  dt        j                          t         j                  dt        j                          t                d t         j                  d       yw)zApplication lifespan managementz)*******FastAPI APPLICATION STARTED*******zEnvironment: zDebug Mode: Nz)*******FastAPI APPLICATION STOPPED*******)loggerinfor   APP_ENV	APP_DEBUGr   )r   s    F/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/src/main.pylifespanr"   5   sc      KK;<
KK- 0 0123
KK,x11234 	 KK;<s   BB	zLA production-ready FastAPI application template with Celery background tasksz	/api/docsz
/api/redoc)titledescriptionversiondebugdocs_url	redoc_urlr"   devzhttps?://.*\.localhost\.comprodzhttps?://.*\.yourdomain\.comT)allow_originsallow_origin_regexallow_credentialsallow_methodsallow_headershttprequestc                 p   K   t        | j                        }|j                  | |       d {   }|S 7 w)N)r   r   dispatch)r1   	call_nextsecurity_middlewareresponses       r!   security_middleware_wrapperr7   f   s5     ,W[[9(11'9EEHO Fs   +646z/uploads)	directoryuploads)name__main__zsrc.main:app)hostportreload	log_level)M__doc__loggingpathlibr   
contextlibr   fastapir   r   fastapi.middleware.corsr   fastapi.staticfilesr   fastapi.exceptionsr	   r
   starlette.middleware.baser   src.core.configr   src.core.routerr   src.core.databaser   src.middleware.errorsr   r   r   r   src.core.exceptionsr   src.middleware.loggingr   src.middleware.securityr   src.middleware.responser   src.apps.files.helper.ior   basicConfiggetattr	LOG_LEVEL	getLoggersetLevelINFO__name__r   r   	Exceptioneerrorsrc.worker.celery_appr   ImportErrorwarningr"   APP_NAMEAPP_VERSIONr    r   ALLOWED_ORIGINSoriginsorigin_regexr   add_middlewareALLOWED_METHODSALLOWED_HEADERS
middlewarer7   add_exception_handlermountUPLOADS_DIRuvicornrunAPP_HOSTAPP_PORTlower     r!   <module>rr      s     * $ 2 + D 8 $ + -  - 4 6 < =   
'8--
.A
   % & / / =			8	$
GLL:;O0
KK01 = = =" 


^  


 
"
" u1L2L   #****   w     + ,   $ %   ,(= >   -)? @   02J K   )%> ?     		(../	 
  zGKK!!$$**, y  
GMM7s;<	
  OJ
NNMNOs*   J) .K )K	.KK	K('K(