[config] add "directory" to config

This specifies where purescript-gargantext/dist directory is.

This way we don't hardcode it in our code and don't force that
purescript-gargantext is strictly under haskell-gargantext.
parent 45371e41
Pipeline #7593 passed with stages
in 41 minutes and 6 seconds
...@@ -103,6 +103,7 @@ convertConfigs ini@(Ini.GargConfig { .. }) iniMail nlpConfig connInfo = ...@@ -103,6 +103,7 @@ convertConfigs ini@(Ini.GargConfig { .. }) iniMail nlpConfig connInfo =
mkFrontendConfig :: Ini.GargConfig -> CTypes.FrontendConfig mkFrontendConfig :: Ini.GargConfig -> CTypes.FrontendConfig
mkFrontendConfig (Ini.GargConfig { .. }) = mkFrontendConfig (Ini.GargConfig { .. }) =
CTypes.FrontendConfig { _fc_url = _gc_url CTypes.FrontendConfig { _fc_url = _gc_url
, _fc_directory = "./purescript-gargantext/dist"
, _fc_backend_name = _gc_backend_name , _fc_backend_name = _gc_backend_name
, _fc_url_backend_api = _gc_url_backend_api , _fc_url_backend_api = _gc_url_backend_api
, _fc_cors , _fc_cors
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
# Main url serving the FrontEnd # Main url serving the FrontEnd
url = "http://localhost" url = "http://localhost"
# Location of the frontend code. This will be served at the root of
# the path (e.g. index.html)
directory = "./purescript-gargantext/dist"
backend_name = "localhost" backend_name = "localhost"
# Main API url serving the BackEnd # Main API url serving the BackEnd
......
...@@ -707,7 +707,6 @@ executable gargantext ...@@ -707,7 +707,6 @@ executable gargantext
, gargantext , gargantext
, gargantext-prelude , gargantext-prelude
, haskell-bee , haskell-bee
, lens >= 5.2.2 && < 5.3
, MonadRandom ^>= 0.6 , MonadRandom ^>= 0.6
, optparse-applicative , optparse-applicative
, postgresql-simple >= 0.6.4 && <= 0.7.0.0 , postgresql-simple >= 0.6.4 && <= 0.7.0.0
......
...@@ -19,6 +19,7 @@ rec { ...@@ -19,6 +19,7 @@ rec {
ghc966 ghc966
cabal_install cabal_install
pkgs.haskellPackages.alex pkgs.haskellPackages.alex
pkgs.haskellPackages.ghcid
pkgs.haskellPackages.happy pkgs.haskellPackages.happy
pkgs.haskellPackages.pretty-show pkgs.haskellPackages.pretty-show
]; ];
......
...@@ -16,9 +16,13 @@ Loads all static file for the front-end. ...@@ -16,9 +16,13 @@ Loads all static file for the front-end.
--------------------------------------------------------------------- ---------------------------------------------------------------------
module Gargantext.API.Admin.FrontEnd where module Gargantext.API.Admin.FrontEnd where
import Gargantext.Core.Config (gc_frontend_config, HasConfig(..))
import Gargantext.Core.Config.Types (fc_directory)
import Gargantext.Prelude
import Servant import Servant
type FrontEndAPI = Raw type FrontEndAPI = Raw
frontEndServer :: Server FrontEndAPI frontEndServer :: (HasConfig env) => env -> Server FrontEndAPI
frontEndServer = serveDirectoryFileServer "./purescript-gargantext/dist" frontEndServer env = do
serveDirectoryFileServer $ env ^. hasConfig . gc_frontend_config . fc_directory
...@@ -66,7 +66,7 @@ server env = ...@@ -66,7 +66,7 @@ server env =
-- (Proxy :: Proxy AuthContext) -- (Proxy :: Proxy AuthContext)
(transformJSON errScheme) (transformJSON errScheme)
Dispatcher.wsServer Dispatcher.wsServer
, frontendAPI = frontEndServer , frontendAPI = frontEndServer env
} }
where where
transformJSON :: forall a. GargErrorScheme -> GargM Env BackendInternalError a -> Handler a transformJSON :: forall a. GargErrorScheme -> GargM Env BackendInternalError a -> Handler a
......
...@@ -28,6 +28,7 @@ module Gargantext.Core.Config.Types ...@@ -28,6 +28,7 @@ module Gargantext.Core.Config.Types
, PortNumber , PortNumber
, FrontendConfig(..) , FrontendConfig(..)
, fc_url , fc_url
, fc_directory
, fc_backend_name , fc_backend_name
, fc_url_backend_api , fc_url_backend_api
, fc_cors , fc_cors
...@@ -200,6 +201,7 @@ defaultCookieSettings = SAuth.defaultCookieSettings { cookieXsrfSetting = Just x ...@@ -200,6 +201,7 @@ defaultCookieSettings = SAuth.defaultCookieSettings { cookieXsrfSetting = Just x
-- TODO jwtSettings = defaultJWTSettings -- TODO jwtSettings = defaultJWTSettings
data FrontendConfig = data FrontendConfig =
FrontendConfig { _fc_url :: !Text FrontendConfig { _fc_url :: !Text
, _fc_directory :: !FilePath
, _fc_backend_name :: !Text , _fc_backend_name :: !Text
, _fc_url_backend_api :: !Text , _fc_url_backend_api :: !Text
, _fc_cors :: !CORSSettings , _fc_cors :: !CORSSettings
...@@ -211,6 +213,7 @@ data FrontendConfig = ...@@ -211,6 +213,7 @@ data FrontendConfig =
instance FromValue FrontendConfig where instance FromValue FrontendConfig where
fromValue = parseTableFromValue $ do fromValue = parseTableFromValue $ do
_fc_url <- reqKey "url" _fc_url <- reqKey "url"
_fc_directory <- reqKey "directory"
_fc_backend_name <- reqKey "backend_name" _fc_backend_name <- reqKey "backend_name"
_fc_url_backend_api <- reqKey "url_backend_api" _fc_url_backend_api <- reqKey "url_backend_api"
_fc_cors <- reqKey "cors" _fc_cors <- reqKey "cors"
...@@ -221,6 +224,7 @@ instance ToValue FrontendConfig where ...@@ -221,6 +224,7 @@ instance ToValue FrontendConfig where
toValue = defaultTableToValue toValue = defaultTableToValue
instance ToTable FrontendConfig where instance ToTable FrontendConfig where
toTable (FrontendConfig { .. }) = table [ "url" .= _fc_url toTable (FrontendConfig { .. }) = table [ "url" .= _fc_url
, "directory" .= _fc_directory
, "backend_name" .= _fc_backend_name , "backend_name" .= _fc_backend_name
, "url_backend_api" .= _fc_url_backend_api , "url_backend_api" .= _fc_url_backend_api
, "cors" .= _fc_cors , "cors" .= _fc_cors
......
[frontend] [frontend]
url = "http://localhost" url = "http://localhost"
backend_name = "localhost" backend_name = "localhost"
directory = "./purescript-gargantext/dist"
url_backend_api = "http://localhost:8008/api/v1.0" url_backend_api = "http://localhost:8008/api/v1.0"
jwt_settings = "TODO" jwt_settings = "TODO"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment