Add Yore.Config

This commit is contained in:
Paul Brinkmeier
2025-08-26 21:54:26 +02:00
parent c1e79230ba
commit c65d366611
3 changed files with 103 additions and 1 deletions
+8
View File
@@ -31,6 +31,7 @@ import Servant
, (:>)
, pattern MkHandler
)
import System.Exit (exitWith, ExitCode (..))
import System.FilePath ((</>))
import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
import Text.Blaze.Html5 ((!))
@@ -50,11 +51,18 @@ import Yore.DB (DayFile (..))
import Yore.Error (Error (..))
import Yore.Time (addYears, getCurrentDay, getSecondsUntilMidnight)
import qualified Yore.Config as Config
import qualified Yore.DB as DB
import qualified Yore.Log as Log
main :: IO ()
main = do
cfg <- Config.load @Config.Config >>= \case
Left err -> do
Log.error err
exitWith $ ExitFailure 1
Right cfg ->
pure cfg
db <- DB.initDB "host=localhost user=yore-test port=5433 dbname=yore-test"
Warp.runSettings settings $ serve (Proxy :: Proxy API) $ hoistServer (Proxy :: Proxy API) nt $ server db
where