get system status endpoint

This commit is contained in:
Lucy Cifferello
2021-05-11 22:16:25 -06:00
parent 46c2c1ef67
commit 1fa68a0ad8
4 changed files with 29 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NamedFieldPuns #-}
module Handler.Types.Status where
@@ -9,6 +10,7 @@ import Yesod.Core.Content
import Lib.Types.Emver
import Orphans.Emver ( )
import Data.Text
data AppVersionRes = AppVersionRes
{ appVersionVersion :: Version
@@ -35,3 +37,22 @@ instance ToContent (Maybe AppVersionRes) where
toContent = toContent . toJSON
instance ToTypedContent (Maybe AppVersionRes) where
toTypedContent = toTypedContent . toJSON
-- status - nothing, available, instuctions
-- version - semver string
data SystemStatus = NOTHING | AVAILABLE | INSTRUCTIONS
deriving (Eq, Show)
instance ToJSON SystemStatus where
toJSON = String . toLower . show
data OSVersionRes = OSVersionRes
{ osVersionStatus :: SystemStatus
, osVersionVersion :: Version
} deriving (Eq, Show)
instance ToJSON OSVersionRes where
toJSON OSVersionRes { .. } = object ["status" .= osVersionStatus, "version" .= osVersionVersion]
instance ToContent OSVersionRes where
toContent = toContent . toJSON
instance ToTypedContent OSVersionRes where
toTypedContent = toTypedContent . toJSON