[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 =
mkFrontendConfig :: Ini.GargConfig -> CTypes.FrontendConfig
mkFrontendConfig (Ini.GargConfig { .. }) =
CTypes.FrontendConfig { _fc_url = _gc_url
, _fc_directory = "./purescript-gargantext/dist"
, _fc_backend_name = _gc_backend_name
, _fc_url_backend_api = _gc_url_backend_api
, _fc_cors
......
......@@ -3,6 +3,10 @@
# Main url serving the FrontEnd
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"
# Main API url serving the BackEnd
......
......@@ -707,7 +707,6 @@ executable gargantext
, gargantext
, gargantext-prelude
, haskell-bee
, lens >= 5.2.2 && < 5.3
, MonadRandom ^>= 0.6
, optparse-applicative
, postgresql-simple >= 0.6.4 && <= 0.7.0.0
......
......@@ -19,6 +19,7 @@ rec {
ghc966
cabal_install
pkgs.haskellPackages.alex
pkgs.haskellPackages.ghcid
pkgs.haskellPackages.happy
pkgs.haskellPackages.pretty-show
];
......
......@@ -16,9 +16,13 @@ Loads all static file for the front-end.
---------------------------------------------------------------------
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
type FrontEndAPI = Raw
frontEndServer :: Server FrontEndAPI
frontEndServer = serveDirectoryFileServer "./purescript-gargantext/dist"
frontEndServer :: (HasConfig env) => env -> Server FrontEndAPI
frontEndServer env = do
serveDirectoryFileServer $ env ^. hasConfig . gc_frontend_config . fc_directory
......@@ -66,7 +66,7 @@ server env =
-- (Proxy :: Proxy AuthContext)
(transformJSON errScheme)
Dispatcher.wsServer
, frontendAPI = frontEndServer
, frontendAPI = frontEndServer env
}
where
transformJSON :: forall a. GargErrorScheme -> GargM Env BackendInternalError a -> Handler a
......
......@@ -28,6 +28,7 @@ module Gargantext.Core.Config.Types
, PortNumber
, FrontendConfig(..)
, fc_url
, fc_directory
, fc_backend_name
, fc_url_backend_api
, fc_cors
......@@ -200,6 +201,7 @@ defaultCookieSettings = SAuth.defaultCookieSettings { cookieXsrfSetting = Just x
-- TODO jwtSettings = defaultJWTSettings
data FrontendConfig =
FrontendConfig { _fc_url :: !Text
, _fc_directory :: !FilePath
, _fc_backend_name :: !Text
, _fc_url_backend_api :: !Text
, _fc_cors :: !CORSSettings
......@@ -211,6 +213,7 @@ data FrontendConfig =
instance FromValue FrontendConfig where
fromValue = parseTableFromValue $ do
_fc_url <- reqKey "url"
_fc_directory <- reqKey "directory"
_fc_backend_name <- reqKey "backend_name"
_fc_url_backend_api <- reqKey "url_backend_api"
_fc_cors <- reqKey "cors"
......@@ -221,6 +224,7 @@ instance ToValue FrontendConfig where
toValue = defaultTableToValue
instance ToTable FrontendConfig where
toTable (FrontendConfig { .. }) = table [ "url" .= _fc_url
, "directory" .= _fc_directory
, "backend_name" .= _fc_backend_name
, "url_backend_api" .= _fc_url_backend_api
, "cors" .= _fc_cors
......
[frontend]
url = "http://localhost"
backend_name = "localhost"
directory = "./purescript-gargantext/dist"
url_backend_api = "http://localhost:8008/api/v1.0"
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