Add Database init effect and integrate with main entrypoint

This commit is contained in:
James Eversole
2024-10-14 11:27:50 -05:00
parent f38e5bc5f5
commit a7836ad08f
2 changed files with 46 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ main :: IO ()
main = do
pool <- createConnectionPool
let env = AppEnv { pool = pool }
runEffStack env $ databaseInit
run port . serve proxy $ app env
app :: AppEnv -> Server AppAPI
@@ -36,7 +37,10 @@ transformEff :: AppEnv -> ServerT AppAPI AppEff -> ServerT AppAPI Handler
transformEff env = hoistServer proxy
$ Handler
. ExceptT
. runEff
. runEffStack env
runEffStack :: AppEnv -> AppEff a -> IO (Either ServerError a)
runEffStack env = runEff
. runErrorNoCallStack
. runReader env
. runDatabaseIO