aboutsummaryrefslogtreecommitdiff
path: root/app/GenJS.hs
blob: 1e7ba3aa272a26a55395ffbf6835fc9f18077c02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE TypeApplications #-}

-- | Just to generate javascript functions so I won't have too much
-- bother with it
module Main where

import           Servant.JS
import           Servant.JS.Vanilla
import           System.Environment (getArgs)
import           Universum

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"