3 {-# LANGUAGE TemplateHaskell #-}
5 module Gargantext.API.Admin.EnvTypes where
8 import Data.Pool (Pool)
9 import Database.PostgreSQL.Simple (Connection)
10 import GHC.Generics (Generic)
11 import Network.HTTP.Client (Manager)
12 import Servant.Client (BaseUrl)
13 import Servant.Job.Async (HasJobEnv(..), Job)
14 import System.Log.FastLogger
15 import qualified Servant.Job.Core
17 import Gargantext.API.Admin.Types
18 import Gargantext.API.Admin.Orchestrator.Types
19 import Gargantext.Core.NodeStory
20 import Gargantext.Core.Mail.Types (HasMail, mailSettings)
21 import Gargantext.Database.Prelude (HasConnectionPool(..), HasConfig(..))
22 import Gargantext.Prelude
23 import Gargantext.Prelude.Config (GargConfig(..))
24 import Gargantext.Prelude.Mail.Types (MailConfig)
27 { _env_settings :: !Settings
28 , _env_logger :: !LoggerSet
29 , _env_pool :: !(Pool Connection)
30 , _env_nodeStory :: !NodeStoryEnv
31 , _env_manager :: !Manager
32 , _env_self_url :: !BaseUrl
33 , _env_scrapers :: !ScrapersEnv
34 , _env_config :: !GargConfig
35 , _env_mail :: !MailConfig
41 instance HasConfig Env where
42 hasConfig = env_config
44 instance HasConnectionPool Env where
47 instance HasNodeStoryEnv Env where
48 hasNodeStory = env_nodeStory
50 instance HasNodeStoryVar Env where
51 hasNodeStoryVar = hasNodeStory . nse_getter
53 instance HasNodeStorySaver Env where
54 hasNodeStorySaver = hasNodeStory . nse_saver
56 instance HasSettings Env where
57 settings = env_settings
59 instance HasMail Env where
60 mailSettings = env_mail
63 instance Servant.Job.Core.HasEnv Env (Job JobLog JobLog) where
64 _env = env_scrapers . Servant.Job.Core._env
66 instance HasJobEnv Env JobLog JobLog where
67 job_env = env_scrapers
69 data MockEnv = MockEnv
70 { _menv_firewall :: !FireWall
79 { _dev_env_settings :: !Settings
80 , _dev_env_config :: !GargConfig
81 , _dev_env_pool :: !(Pool Connection)
82 , _dev_env_nodeStory :: !NodeStoryEnv
83 , _dev_env_mail :: !MailConfig
88 instance HasConfig DevEnv where
89 hasConfig = dev_env_config
91 instance HasConnectionPool DevEnv where
92 connPool = dev_env_pool
94 instance HasSettings DevEnv where
95 settings = dev_env_settings
98 instance HasNodeStoryEnv DevEnv where
99 hasNodeStory = dev_env_nodeStory
101 instance HasNodeStoryVar DevEnv where
102 hasNodeStoryVar = hasNodeStory . nse_getter
104 instance HasNodeStorySaver DevEnv where
105 hasNodeStorySaver = hasNodeStory . nse_saver
107 instance HasMail DevEnv where
108 mailSettings = dev_env_mail