---------------------------------------------------------------------
module Gargantext.API.Server where
---------------------------------------------------------------------
+import Control.Lens ((^.))
import Control.Monad.Except (withExceptT)
import Control.Monad.Reader (runReaderT)
import Data.Text (Text)
import qualified Gargantext.API.Public as Public
-import Gargantext.API.Admin.Auth (AuthContext, auth)
+import Gargantext.API.Admin.Auth.Types (AuthContext)
+import Gargantext.API.Admin.Auth (auth)
import Gargantext.API.Admin.FrontEnd (frontEndServer)
import Gargantext.API.Prelude
import Gargantext.API.Routes
import Gargantext.API.Swagger (swaggerDoc)
import Gargantext.API.ThrowAll (serverPrivateGargAPI)
import Gargantext.Prelude
+import Gargantext.Prelude.Config (gc_url_backend_api)
+import Gargantext.Database.Prelude (hasConfig)
serverGargAPI :: Text -> GargServerM env err GargAPI
gargVersion = pure (cs $ showVersion PG.version)
-- | Server declarations
-server :: forall env. EnvC env => env -> Text -> IO (Server API)
-server env baseUrl = do
+server :: forall env. EnvC env => env -> IO (Server API)
+server env = do
-- orchestrator <- scrapyOrchestrator env
pure $ swaggerSchemaUIServer swaggerDoc
:<|> hoistServerWithContext
(Proxy :: Proxy GargAPI)
(Proxy :: Proxy AuthContext)
transform
- (serverGargAPI baseUrl)
+ (serverGargAPI (env ^. hasConfig . gc_url_backend_api))
:<|> frontEndServer
where
transform :: forall a. GargM env GargError a -> Handler a
showAsServantErr :: GargError -> ServerError
showAsServantErr (GargServerError err) = err
-showAsServantErr a = err500 { errBody = BL8.pack $ show a }
\ No newline at end of file
+showAsServantErr a = err500 { errBody = BL8.pack $ show a }