2022-07-01 20:34:29 -05:00
|
|
|
module Lib ( main ) where
|
2022-06-28 20:30:09 -05:00
|
|
|
|
2022-07-02 18:37:30 -05:00
|
|
|
import Core.Types
|
2022-07-01 20:34:29 -05:00
|
|
|
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
|