
    Ch                         d dl Z d dlmZ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 d dlmZ d dlmZ d dlmZ  e         e       Z e j2                  d      gZej7                  ed	gd
d	gd	g       ej9                  e
      dede
fd       Zej9                  e      defd       Zej?                  ed       ej?                  ed       ej?                  ed       ej?                  ed       y)    N)FastAPI	APIRouterDependsHTTPExceptionRequest)CORSMiddleware)RequestValidationError)JSONResponse)load_dotenv)routerFRONT_APP_URL*T)allow_originsallow_credentialsallow_methodsallow_headersrequestexcc                    K   |j                         D cg c]'  }dj                  d |d   D              |d   |d   d) }}t        dd|d   d	   |d   d
   d      S c c}w w)N.c              3   2   K   | ]  }t        |        y w)N)str).0locs     /var/www/html/answerous/app.py	<genexpr>z6custom_validation_exception_handler.<locals>.<genexpr>    s     ?3c#h?s   r   msgtype)fieldmessager   i  r   r    r   )statusr    r   status_codecontent)errorsjoinr
   )r   r   errorr%   s       r   #custom_validation_exception_handlerr(      s      ZZ\ 	 XX?%,??U|&M	
F  ay+AYw'
 s   A%,A $A%c                    K   |j                   dk(  r|j                  dk(  rt        dddd      S t        |j                   |j                   |j                  d      S w)Ni  zNot authenticatedi  zMissing API Token)r!   r    r"   )r#   detailr
   )r   r   s     r   custom_http_exception_handlerr+   0   s]     
##**0C"C"/BC
 	
 OO??szzB s   AAz/users)prefixz/foldersz
/documentsz/search) osfastapir   r   r   r   r   fastapi.middleware.corsr   fastapi.exceptionsr	   fastapi.responsesr
   dotenvr   routers.authr   auth_routerrouters.foldersfolder_routerrouters.chromadocdocument_routerrouters.searchsearch_routerappgetenvr   add_middlewareexception_handlerr(   r+   include_router     r   <module>rB      s   	 G G 2 5 *  . 3 7 2 iryy)*   %%%   -.w E[  /& }%	m 	 &	   ;x  0   =  4   ?<  8   =  3rA   