o
    3i                     @   s  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 d dlmZmZmZ ed	Zejd
d edddZejedgd
dgdgd eddd Zeddd Zee ejdeeddd ejdedddd eedefdd Zeedefd!d"Zeedefd#d$Zeedefd%d&Z ed'defd(d)Z!ed*defd+d,Z"d-S ).    )Path)FastAPIRequest)RequestValidationError)CORSMiddleware)JSONResponse)StaticFiles)router)CoreValidationErrorCoreDBErrorGenericErrorZuploadsT)exist_okWAC API0.0.23)titleversionzhttps://app.wacarts.co.uk*)Zallow_originsZallow_credentialsZallow_methodsZallow_headersz/healthc                         ddddS )z7Health check endpoint for monitoring and load balancersZhealthyr   r   )statusr   Zservice r   r   r   /app/main.pyhealth_check   
   r   /c                      r   )zRoot endpointzWAC API is runningr   Zactive)messager   r   r   r   r   r   r   root"   r   r   z/images)	directoryZimages)namez/staticZstaticrequestc              	          t dtg dt|g dddS N  zrequest validation errorFZ
error_logserrorr   datar   status_codecontentr   dictstrr   excr   r   r   validation_exception/      r-   c              	      r   r    r(   r+   r   r   r   validation_exception_handler<   r.   r/   c              	      $   t dtg t|t|g dddS )Nr!   Fr"   r%   r(   r+   r   r   r   db_exception_handlerI      r1   c              	      s&   t |jtg t|t|g dddS )NFr"   r%   )r   r&   r)   r*   r+   r   r   r   generic_exception_handlerV   s   r3     c              	      r0   )Nr4   Fr"   r%   r(   r+   r   r   r   internal_error_handlerc   r2   r5     c              	      r0   )Nr6   Fr"   r%   r(   r+   r   r   r   unauthorized_handlerp   r2   r7   N)#pathlibr   Zfastapir   r   Zfastapi.exceptionsr   Zfastapi.middleware.corsr   Zfastapi.responsesr   Zfastapi.staticfilesr   Zapir	   Zcore.security.exceptionsr
   r   r   Z
UPLOAD_DIRmkdirappZadd_middlewaregetr   r   Zinclude_routerZmountZexception_handlerr-   r/   r1   r3   r5   r7   r   r   r   r   <module>   sJ    	
	

