5import Data.Int (fromString)
6import Data.Maybe (fromMaybe)
8import Effect.Class.Console (info)
9import Node.Encoding (Encoding(..))
10import Node.Express.App (App, listenHttp, listenHttps, use)
12import Node.Express.Middleware.Static (static)
13import Node.FS.Sync (readTextFile)
14import Node.HTTP (Server)
15import Node.Process (lookupEnv)
24 -- useOnError (errorHandler log)
27 = UseLocalCertificates
28 | DoNotUseLocalCertificates
30parseCertificatesToUse :: String -> CertificatesToUse
31parseCertificatesToUse = case _ of
32 "LOCAL" -> UseLocalCertificates
33 _ -> DoNotUseLocalCertificates
35serverSetup ∷ App -> Effect Server
37 maybePortString <- lookupEnv "PORT"
38 let port = maybePortString >>= fromString # fromMaybe 14188
39 useLocalCertificates <- fromMaybe DoNotUseLocalCertificates <<< map parseCertificatesToUse <$> lookupEnv "CERTS"
40 listen <- case useLocalCertificates of
41 UseLocalCertificates -> do
42 httpsOptions <- makeHttpsOptions
43 pure $ listenHttps app (port ∷ Int) httpsOptions
44 DoNotUseLocalCertificates ->
45 pure $ listenHttp app port
46 listen \_ -> info $ "psfp server started on port " <> show port
49 key <- readTextFile UTF8 "server.key"
50 cert <- readTextFile UTF8 "server.cert"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list