diff --git a/server/Main.hs b/server/Main.hs index 18823a65..fba29505 100644 --- a/server/Main.hs +++ b/server/Main.hs @@ -21,6 +21,7 @@ import qualified Data.Aeson as A import Data.Aeson ((.=)) import Data.Bifunctor (first, second) import qualified Data.ByteString.Lazy as BL +import Data.Default (def) import Data.Function (on) import Data.List (foldl', nubBy) import qualified Data.List.NonEmpty as NE @@ -41,6 +42,7 @@ import qualified Language.PureScript.CoreFn as CF import qualified Language.PureScript.Errors.JSON as P import qualified Language.PureScript.Interactive as I import qualified Language.PureScript.TypeChecker.TypeSearch as TS +import qualified Network.Wai.Handler.Warp as Warp import System.Environment (getArgs) import System.Exit (exitFailure) import System.FilePath (()) @@ -89,7 +91,7 @@ server externs initNamesEnv initEnv port = do Right _ -> (return . Left . OtherError) "The name of the main module should be Main." - scotty port $ do + scottyOpts (getOpts port) $ do get "/" $ Scotty.text "POST api.purescript.org/compile" post "/compile" $ do @@ -120,6 +122,14 @@ server externs initNamesEnv initEnv port = do ] ] +getOpts :: Int -> Scotty.Options +getOpts port = def + { settings = + Warp.setHost "127.0.0.1" + $ Warp.setPort port + $ Warp.defaultSettings + } + lookupAllConstructors :: P.Environment -> P.SourceType -> [P.SourceType] lookupAllConstructors env = P.everywhereOnTypesM $ \case P.TypeConstructor ann (P.Qualified Nothing tyCon) -> P.TypeConstructor ann <$> lookupConstructor env tyCon diff --git a/trypurescript.cabal b/trypurescript.cabal index d51a452b..f3500e50 100644 --- a/trypurescript.cabal +++ b/trypurescript.cabal @@ -16,6 +16,7 @@ executable trypurescript build-depends: base ==4.*, aeson -any, bytestring >=0.10.0.2 && <0.11, + data-default -any, directory -any, filepath -any, Glob -any, @@ -27,7 +28,8 @@ executable trypurescript mtl ==2.2.2, parsec, text -any, - time -any + time -any, + warp -any hs-source-dirs: server main-is: Main.hs buildable: True