Initial project skeleton
Haskell backend: Orb HTTP framework, JSON-only API Frontend: Mithril.js SPA with TypeScript, Neo Brutalism CSS Dockerized build via flipstone/haskell-tools image Routes: GET /api/health — health check Build: ./hs stack build Test: ./hs stack test Run: ./scripts/run
This commit is contained in:
+53
@@ -0,0 +1,53 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
{- | Entry point for the Sis chore tracker server.
|
||||
|
||||
Starts a Warp HTTP server and serves the JSON API.
|
||||
-}
|
||||
module Main (main) where
|
||||
|
||||
import Network.Wai.Handler.Warp qualified as Warp
|
||||
import Options.Applicative qualified as Opt
|
||||
import System.Posix.Signals qualified as Signals
|
||||
|
||||
import Sis.Server qualified as Sis
|
||||
|
||||
data Options = Options
|
||||
{ optPort :: Int
|
||||
}
|
||||
|
||||
optionsParser :: Opt.Parser Options
|
||||
optionsParser =
|
||||
Options
|
||||
<$> Opt.option
|
||||
Opt.auto
|
||||
( Opt.long "port"
|
||||
<> Opt.short 'p'
|
||||
<> Opt.metavar "PORT"
|
||||
<> Opt.help "Listen port"
|
||||
<> Opt.value 8080
|
||||
<> Opt.showDefault
|
||||
)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
opts <- Opt.execParser $
|
||||
Opt.info (optionsParser Opt.<**> Opt.helper) $
|
||||
Opt.fullDesc
|
||||
<> Opt.progDesc "Sis — shared household chore tracker"
|
||||
<> Opt.header "sis-server"
|
||||
|
||||
-- Install a SIGTERM handler so Docker stop works cleanly.
|
||||
_ <- Signals.installHandler
|
||||
Signals.sigTERM
|
||||
(Signals.Catch (putStrLn "[sis] shutting down"))
|
||||
Nothing
|
||||
|
||||
let waiApp = Sis.app
|
||||
|
||||
let settings =
|
||||
Warp.setPort (optPort opts)
|
||||
$ Warp.setBeforeMainLoop (putStrLn $ "[sis] listening on port " ++ show (optPort opts))
|
||||
Warp.defaultSettings
|
||||
|
||||
Warp.runSettings settings waiApp
|
||||
Reference in New Issue
Block a user