zenith/app/Server.hs

24 lines
772 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
module Server where
import Data.Configurator
import Network.Wai.Handler.Warp (run)
import Servant
import Zenith.RPC (ZenithRPC(..), authenticate, zenithServer)
import Zenith.Types (Config(..))
main :: IO ()
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
run nodePort $
serveWithContext (Proxy :: Proxy ZenithRPC) ctx (zenithServer myConfig)