purr/src/Lib.hs

24 lines
796 B
Haskell
Raw Normal View History

module Lib ( main ) where
import Core.Types
import qualified Core.Configuration as Configuration
import qualified Core.HTTP as HTTP
import qualified Core.Mongo as DB
import Control.Monad.Reader (liftIO, runReaderT)
import Database.MongoDB (MongoContext)
import GHC.Natural (popCountNatural)
import Web.Scotty.Trans (scottyT)
import Prelude hiding (id)
main :: IO ()
main = do
dhallConf <- liftIO Configuration.main
dataDB <- liftIO $ DB.mongoSetup dhallConf
let config = AppConfig { res = dhallConf
, dbconn = dataDB
}
scottyT (port dhallConf) (flip runApp config) HTTP.app where
runApp :: ConfigM a -> AppConfig -> IO a
runApp m c = runReaderT (runConfigM m) c