aboutsummaryrefslogtreecommitdiff
path: root/app/Main.hs
diff options
context:
space:
mode:
authorstuebinm2022-06-16 00:25:15 +0200
committerstuebinm2022-06-16 00:25:15 +0200
commit9e89c93b3b84b5c82c186cff62c33218a0a4d298 (patch)
treef810fc1eacc7b82e82543196257a2e93c5f21a9f /app/Main.hs
parentd418ad82c98ab8dd3d540e910777fa530de350eb (diff)
actually use the database
(at least for a few simple things) Also, more modules!
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 0b3165e..7d3b5dc 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -26,16 +26,21 @@ import Network.Wai.Handler.Warp (run)
import Network.Wai.Middleware.RequestLogger (OutputFormat (..),
RequestLoggerSettings (..),
mkRequestLogger)
+import Database.Persist.Postgresql
+import Control.Monad.Logger (runStderrLoggingT)
+import Control.Monad.IO.Class (MonadIO (liftIO))
import GTFS
import Server
+connStr = "user=travelynx"
main :: IO ()
main = do
gtfs <- loadGtfs "./gtfs.zip"
- app <- application gtfs
loggerMiddleware <- mkRequestLogger
$ def { outputFormat = Detailed True }
- putStrLn "starting server …"
- run 4000 (loggerMiddleware app)
+ runStderrLoggingT $ withPostgresqlPool connStr 10 $ \pool -> liftIO $ do
+ app <- application gtfs pool
+ putStrLn "starting server …"
+ run 4000 (loggerMiddleware app)