aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/GenJS.hs24
-rw-r--r--haskell-gtfs.cabal12
2 files changed, 36 insertions, 0 deletions
diff --git a/app/GenJS.hs b/app/GenJS.hs
new file mode 100644
index 0000000..a580d23
--- /dev/null
+++ b/app/GenJS.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE TypeApplications #-}
+
+-- | Just to generate javascript functions so I won't have too much
+-- bother with it
+module Main where
+
+import Universum
+import Servant.JS
+import Servant.JS.Vanilla
+import System.Environment (getArgs)
+
+import API
+
+apiJS :: Text -> Text
+apiJS url = jsForAPI (Proxy @API) (vanillaJSWith options)
+ where options = defCommonGeneratorOptions { urlPrefix = url }
+
+main :: IO ()
+main = do
+ args <- getArgs
+ case args of
+ [] -> putText (apiJS "")
+ [prefix] -> putText (apiJS (toText prefix))
+ _ -> error "don't understand these options"
diff --git a/haskell-gtfs.cabal b/haskell-gtfs.cabal
index 0396a5c..ec312ee 100644
--- a/haskell-gtfs.cabal
+++ b/haskell-gtfs.cabal
@@ -39,6 +39,18 @@ executable tracktrain
default-extensions: OverloadedStrings
, ScopedTypeVariables
+-- executable gen-js
+-- main-is: GenJS.hs
+-- build-depends: base ^>=4.14.3.0
+-- , servant-js
+-- , tracktrain
+-- , universum
+-- hs-source-dirs: app
+-- default-language: Haskell2010
+-- default-extensions: OverloadedStrings
+-- , ScopedTypeVariables
+-- , NoImplicitPrelude
+
library
build-depends: base ^>=4.14.3.0