diff options
author | stuebinm | 2022-06-17 23:01:24 +0200 |
---|---|---|
committer | stuebinm | 2022-06-17 23:01:24 +0200 |
commit | 815755861152fb0e3dfdd9b6321f8f74e7bf8515 (patch) | |
tree | 8c0ae23e77842d786496c244918045c98df67b86 /app | |
parent | c45ed0661ff5ea102e1e4ab1ed59945df57c619e (diff) |
generate javascript functions
(this is commented out in the cabal file, since unfortunately the
servant-js package is broken in nixpkgs and therefore otherwise breaks
the nix build process … but it can be used "by hand")
Diffstat (limited to 'app')
-rw-r--r-- | app/GenJS.hs | 24 |
1 files changed, 24 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" |