zenith/app/Server.hs

24 lines
768 B
Haskell
Raw Normal View History

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
run 8081 $
serveWithContext (Proxy :: Proxy ZenithRPC) ctx (zenithServer myConfig)