aboutsummaryrefslogtreecommitdiff
path: root/lib/Server
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Server')
-rw-r--r--lib/Server/GTFS_RT.hs3
-rw-r--r--lib/Server/Util.hs13
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/Server/GTFS_RT.hs b/lib/Server/GTFS_RT.hs
index e2b23e0..85ea8cd 100644
--- a/lib/Server/GTFS_RT.hs
+++ b/lib/Server/GTFS_RT.hs
@@ -65,6 +65,7 @@ import Servant.API ((:<|>) (..))
import Servant.Server (Handler (Handler),
Server)
+import Server.Util (Service)
uuidUtf8 :: UUID.UUID -> Utf8
uuidUtf8 = Utf8 . fromStrict . UUID.toASCIIBytes
@@ -86,7 +87,7 @@ toStupidDate date = toUtf8
toStupidTime :: UTCTime -> Word64
toStupidTime = fromIntegral . systemSeconds . utcToSystemTime
-gtfsRealtimeServer :: GTFS -> Pool SqlBackend -> Server GtfsRealtimeAPI
+gtfsRealtimeServer :: GTFS -> Pool SqlBackend -> Service GtfsRealtimeAPI
gtfsRealtimeServer gtfs dbpool = handleServiceAlerts :<|> handleTripUpdates :<|> handleVehiclePositions
where handleServiceAlerts = runSql dbpool $ do
-- TODO filter: only select current & future days
diff --git a/lib/Server/Util.hs b/lib/Server/Util.hs
new file mode 100644
index 0000000..45c2477
--- /dev/null
+++ b/lib/Server/Util.hs
@@ -0,0 +1,13 @@
+
+
+-- | mostly the monad the service runs in
+module Server.Util (Service, ServiceM, runService) where
+
+import Control.Monad.Logger (LoggingT, runStderrLoggingT)
+import Servant (Handler, ServerT)
+
+type ServiceM = LoggingT Handler
+type Service api = ServerT api ServiceM
+
+runService :: ServiceM a -> Handler a
+runService = runStderrLoggingT