Commit 92e50de6 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[INI] clean + fix + add todos

parent e6229776
Pipeline #1003 failed with stage
......@@ -5,9 +5,11 @@ MASTER_USER = gargantua
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = PASSWORD_TO_CHANGE
# Data path to local files
DATA_FILEPATH = FILEPATH_TO_CHANGE
# [external]
# FRAMES
FRAME_WRITE_URL = URL_TO_CHANGE
FRAME_CALC_URL = URL_TO_CHANGE
......@@ -15,6 +17,17 @@ FRAME_CALC_URL = URL_TO_CHANGE
FRAME_SEARX_URL = URL_TO_CHANGE
FRAME_ISTEX_URL = URL_TO_CHANGE
[server]
# Server config (TODO connect in ReaderMonad)
ALLOWED_ORIGIN = http://localhost
ALLOWED_ORIGIN_PORT = 8008
ALLOWED_HOST = localhost
ALLOWED_HOST_PORT = 3000
JWT_SETTINGS = TODO
[network]
# Emails From address (sent by smtp)
MAIL = username@gargantext.org
......@@ -33,5 +46,5 @@ DB_PASS = PASSWORD_TO_CHANGE
[logs]
LOG_FILE = /var/log/gargantext/backend.log
LOG_LEVEL = DEBUG
LOG_LEVEL = LevelDebug
LOG_FORMATTER = verbose
......@@ -75,7 +75,6 @@ data Settings = Settings
, _cookieSettings :: CookieSettings
, _sendLoginEmails :: SendEmailType
, _scrapydUrl :: BaseUrl
, _fileFolder :: FilePath
, _config :: GargConfig
}
......@@ -97,7 +96,6 @@ devSettings jwkFile = do
-- , _dbServer = "localhost"
, _sendLoginEmails = LogEmailToConsole
, _scrapydUrl = fromMaybe (panic "Invalid scrapy URL") $ parseBaseUrl "http://localhost:6800"
, _fileFolder = "data"
, _cookieSettings = defaultCookieSettings { cookieXsrfSetting = Just xsrfCookieSetting } -- TODO-SECURITY tune
, _jwtSettings = defaultJWTSettings jwk -- TODO-SECURITY tune
, _config = defaultConfig
......
......@@ -24,7 +24,7 @@ import Control.Lens (makeLenses)
data GargConfig = GargConfig { _gc_masteruser :: !Text
, _gc_secretkey :: !Text
, _gc_datafilepath :: !Text
, _gc_datafilepath :: !FilePath
, _gc_frame_write_url :: !Text
, _gc_frame_calc_url :: !Text
......@@ -36,7 +36,6 @@ data GargConfig = GargConfig { _gc_masteruser :: !Text
makeLenses ''GargConfig
readConfig :: FilePath -> IO GargConfig
readConfig fp = do
ini <- readIniFile fp
......@@ -50,7 +49,7 @@ readConfig fp = do
pure $ GargConfig (val "MASTER_USER")
(val "SECRET_KEY")
(val "DATA_FILEPATH")
(cs $ val "DATA_FILEPATH")
(val "FRAME_WRITE_URL")
(val "FRAME_CALC_URL")
(val "FRAME_SEARX_URL")
......
......@@ -20,6 +20,7 @@ import Control.Monad.Reader (MonadReader)
import Control.Monad.Reader (ask)
import Data.Text (Text)
import GHC.IO (FilePath)
import Gargantext.Config
import Gargantext.API.Admin.Settings
import Gargantext.Database.Admin.Types.Node (NodeId, NodeType)
import Gargantext.Prelude
......@@ -65,7 +66,7 @@ class ReadFile a where
writeFile :: (MonadReader env m, MonadBase IO m, HasSettings env, SaveFile a)
=> a -> m FilePath
writeFile a = do
dataPath <- view (settings . fileFolder) <$> ask
dataPath <- view (settings . config . gc_datafilepath) <$> ask
(fp,fn) <- liftBase $ (toPath 3) . hash . show <$> newStdGen
let foldPath = dataPath <> "/" <> fp
......@@ -80,5 +81,5 @@ writeFile a = do
readFile :: (MonadReader env m, MonadBase IO m, HasSettings env, ReadFile a)
=> FilePath -> m a
readFile fp = do
dataPath <- view (settings . fileFolder) <$> ask
dataPath <- view (settings . config . gc_datafilepath) <$> ask
liftBase $ readFile' $ dataPath <> "/" <> fp
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