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 HasNodeStoryImmediateSaver Env where
57 hasNodeStoryImmediateSaver = hasNodeStory . nse_saver_immediate
59 instance HasSettings Env where
60 settings = env_settings
62 instance HasMail Env where
63 mailSettings = env_mail
66 instance Servant.Job.Core.HasEnv Env (Job JobLog JobLog) where
67 _env = env_scrapers . Servant.Job.Core._env
69 instance HasJobEnv Env JobLog JobLog where
70 job_env = env_scrapers
72 data MockEnv = MockEnv
73 { _menv_firewall :: !FireWall
82 { _dev_env_settings :: !Settings
83 , _dev_env_config :: !GargConfig
84 , _dev_env_pool :: !(Pool Connection)
85 , _dev_env_nodeStory :: !NodeStoryEnv
86 , _dev_env_mail :: !MailConfig
91 instance HasConfig DevEnv where
92 hasConfig = dev_env_config
94 instance HasConnectionPool DevEnv where
95 connPool = dev_env_pool
97 instance HasSettings DevEnv where
98 settings = dev_env_settings
101 instance HasNodeStoryEnv DevEnv where
102 hasNodeStory = dev_env_nodeStory
104 instance HasNodeStoryVar DevEnv where
105 hasNodeStoryVar = hasNodeStory . nse_getter
107 instance HasNodeStorySaver DevEnv where
108 hasNodeStorySaver = hasNodeStory . nse_saver
110 instance HasNodeStoryImmediateSaver DevEnv where
111 hasNodeStoryImmediateSaver = hasNodeStory . nse_saver_immediate
113 instance HasMail DevEnv where
114 mailSettings = dev_env_mail