Config.purs 2.61 KB
Newer Older
1 2
module Gargantext.Config where

3 4 5
import Data.String as S
import Web.HTML.Location (Location(..))
import Effect (Effect)
6 7 8
import Data.NonEmpty (NonEmpty, (:|), head)
import Gargantext.Ends
import Gargantext.Types (ApiVersion(..))
9 10
import Gargantext.Utils (location)
import Gargantext.Prelude (bind, pure, ($))
Nicolas Pouillard's avatar
Nicolas Pouillard committed
11

James Laver's avatar
James Laver committed
12
defaultBackends :: NonEmpty Array Backend
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
defaultBackends = backend_local :| [ backend_prod
                                   , backend_partner
                                   , backend_demo
                                   , backend_dev
                                   ]

backend_prod :: Backend
backend_prod    = backend V10 "/api/" "https://v4.gargantext.org"    "iscpif.cnrs"

backend_partner :: Backend
backend_partner = backend V10 "/api/" "https://imtv4.gargantext.org" "institut-mines-telecom.imt"

backend_demo :: Backend
backend_demo    = backend V10 "/api/" "https://demo.gargantext.org"  "demo.inshs.cnrs"

backend_dev :: Backend
backend_dev     = backend V10 "/api/" "https://dev.gargantext.org"   "devel.inshs.cnrs"

backend_local :: Backend
backend_local   = backend V10 "/api/" "http://localhost:8008"        "local.cnrs"


-- | public Backend
-- When user is not logged, use the location of the window
publicBackend :: Backend
38
publicBackend = backend_local
39 40 41 42 43 44 45 46 47 48 49


publicBackend' :: Effect Backend
publicBackend' = do
  url <- location
  pure $ Backend { name  : "Public Backend"
                 , baseUrl : url
                 , prePath : "api/"
                 , version : V10
                 }

50

51
defaultApps :: NonEmpty Array Frontend
52
defaultApps = relative :| [prod, dev, demo, haskell, caddy]
James Laver's avatar
James Laver committed
53
  where
54 55 56
    relative = frontend "/#/" ""                            "Relative"
    prod     = frontend "/#/" "https://v4.gargantext.org"   "v4.gargantext.org"
    dev      = frontend "/#/" "https://dev.gargantext.org"  "gargantext.org (dev)"
57
    demo     = frontend "/#/" "https://demo.gargantext.org" "gargantext.org (demo)"
58 59 60
    haskell  = frontend "/#/" "http://localhost:8008"       "localhost.gargantext"
    python   = frontend "/#/" "http://localhost:8000"       "localhost.python"
    caddy    = frontend "/#/" "http://localhost:2015"       "localhost.caddy"
James Laver's avatar
James Laver committed
61 62 63 64 65 66

defaultStatics :: NonEmpty Array Frontend
defaultStatics = relative :| []
  where
    relative = frontend "" "/" "relative"

67 68
defaultApp :: Frontend
defaultApp = head defaultApps
69

70 71
defaultStatic :: Frontend
defaultStatic = head defaultStatics
72

73 74
defaultFrontends :: Frontends
defaultFrontends = Frontends { app: defaultApp, static: defaultStatic }
75

76 77 78 79
changePort :: String -> String
changePort = S.replace (S.Pattern "http://localhost:8000/") (S.Replacement "http://localhost:8008/")