Use SERIAL for users id field; general cleanup

This commit is contained in:
James Eversole
2024-10-14 13:05:17 -05:00
parent a7836ad08f
commit 0808fe130a
3 changed files with 38 additions and 41 deletions

View File

@@ -20,31 +20,27 @@ import qualified Servant as S
--
main :: IO ()
main = do
pool <- createConnectionPool
pool <- createConnectionPool
let env = AppEnv { pool = pool }
runEffStack env $ databaseInit
runAppEff env $ databaseInit
run port . serve proxy $ app env
app :: AppEnv -> Server AppAPI
app env = transformEff env
$ rootHandler
:<|> userListHandler
:<|> userGetHandler
:<|> userPostHandler
:<|> userDeleteHandler
app env = hoistServer proxy (Handler . ExceptT . runAppEff env) handlers
transformEff :: AppEnv -> ServerT AppAPI AppEff -> ServerT AppAPI Handler
transformEff env = hoistServer proxy
$ Handler
. ExceptT
. runEffStack env
handlers :: ServerT AppAPI AppEff
handlers = rootHandler
:<|> userListHandler
:<|> userGetHandler
:<|> userPostHandler
:<|> userDeleteHandler
runEffStack :: AppEnv -> AppEff a -> IO (Either ServerError a)
runEffStack env = runEff
. runErrorNoCallStack
. runReader env
. runDatabaseIO
. runLoggerPSQL
runAppEff :: AppEnv -> AppEff a -> IO (Either ServerError a)
runAppEff env = runEff
. runErrorNoCallStack
. runReader env
. runDatabaseIO
. runLoggerPSQL
port :: Int
port = 8080