2024-07-24 21:03:49 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
2024-07-23 18:46:37 +00:00
|
|
|
module Server where
|
|
|
|
|
2024-07-24 21:03:49 +00:00
|
|
|
import Data.Configurator
|
2024-07-23 18:46:37 +00:00
|
|
|
import Network.Wai.Handler.Warp (run)
|
|
|
|
import Servant
|
2024-07-24 21:03:49 +00:00
|
|
|
import Zenith.RPC (ZenithRPC(..), authenticate, zenithServer)
|
|
|
|
import Zenith.Types (Config(..))
|
2024-07-23 18:46:37 +00:00
|
|
|
|
|
|
|
main :: IO ()
|
2024-07-24 21:03:49 +00:00
|
|
|
main = do
|
|
|
|
config <- load ["$(HOME)/Zenith/zenith.cfg"]
|
|
|
|
dbFilePath <- require config "dbFilePath"
|
|
|
|
nodeUser <- require config "nodeUser"
|
|
|
|
nodePwd <- require config "nodePwd"
|
|
|
|
zebraPort <- require config "zebraPort"
|
|
|
|
zebraHost <- require config "zebraHost"
|
|
|
|
nodePort <- require config "nodePort"
|
|
|
|
let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort
|
|
|
|
let ctx = authenticate myConfig :. EmptyContext
|
2024-07-24 21:13:13 +00:00
|
|
|
run nodePort $
|
2024-07-24 21:03:49 +00:00
|
|
|
serveWithContext (Proxy :: Proxy ZenithRPC) ctx (zenithServer myConfig)
|