diff --git a/projects/mirza-common-haskell/src/Mirza/Common/Types.hs b/projects/mirza-common-haskell/src/Mirza/Common/Types.hs index a6b6f37f..ba851dac 100644 --- a/projects/mirza-common-haskell/src/Mirza/Common/Types.hs +++ b/projects/mirza-common-haskell/src/Mirza/Common/Types.hs @@ -21,6 +21,7 @@ module Mirza.Common.Types ( EmailAddress, emailToText, Password(..) , UserId(..) , ORKeyId(..) + , HealthResponse(..) , EnvType(..) , AppM(..) , runAppM @@ -85,6 +86,7 @@ import Text.Email.Validate (EmailAddress, toByteString, validate) import Data.Aeson +import Data.Aeson.Types import Control.Lens import Control.Monad.Error.Lens @@ -216,6 +218,23 @@ newtype DB context error a = DB (ReaderT (Connection,context) (ExceptT error Pg) , MonadIO -- Need to figure out if we actually want this ) + +-- Health Types: +successHealthResponseText :: Text +successHealthResponseText = "Status OK" + +data HealthResponse = HealthResponse + deriving (Show, Eq, Read, Generic) +instance ToSchema HealthResponse +instance ToJSON HealthResponse where + toJSON _ = toJSON successHealthResponseText +instance FromJSON HealthResponse where + parseJSON (String value) + | value == successHealthResponseText = pure HealthResponse + | otherwise = fail "Invalid health response string." + parseJSON value = typeMismatch "HealthResponse" value + + -- ============================================================================= -- Classes and utilities for working with Constraints -- ============================================================================= diff --git a/projects/or_scs/src/Mirza/OrgRegistry/Handlers/Health.hs b/projects/or_scs/src/Mirza/OrgRegistry/Handlers/Health.hs index f78db348..2b8051d1 100644 --- a/projects/or_scs/src/Mirza/OrgRegistry/Handlers/Health.hs +++ b/projects/or_scs/src/Mirza/OrgRegistry/Handlers/Health.hs @@ -3,7 +3,7 @@ module Mirza.OrgRegistry.Handlers.Health ) where -import Mirza.OrgRegistry.Types as ORT +import Mirza.Common.Types -- | Currently the health check always returns success and is basically just a diff --git a/projects/or_scs/src/Mirza/OrgRegistry/Types.hs b/projects/or_scs/src/Mirza/OrgRegistry/Types.hs index 8437a433..90909e4f 100644 --- a/projects/or_scs/src/Mirza/OrgRegistry/Types.hs +++ b/projects/or_scs/src/Mirza/OrgRegistry/Types.hs @@ -51,7 +51,6 @@ import Katip as K import Network.URI (URI) import Data.Aeson -import Data.Aeson.Types import Data.Swagger (NamedSchema (..), SwaggerType (..), @@ -409,21 +408,6 @@ instance ToJSON KeyState where instance ToSchema KeyState instance ToParamSchema KeyState --- Health Types: -successHealthResponseText :: Text -successHealthResponseText = "Status OK" - -data HealthResponse = HealthResponse - deriving (Show, Eq, Read, Generic) -instance ToSchema HealthResponse -instance ToJSON HealthResponse where - toJSON _ = toJSON successHealthResponseText -instance FromJSON HealthResponse where - parseJSON (String value) - | value == successHealthResponseText = pure HealthResponse - | otherwise = fail "Invalid health response string." - parseJSON value = typeMismatch "HealthResponse" value - -- ***************************************************************************** -- Signing and Hashing Types diff --git a/projects/or_scs/src/Mirza/SupplyChain/Types.hs b/projects/or_scs/src/Mirza/SupplyChain/Types.hs index 1465c9e1..a5440bfb 100644 --- a/projects/or_scs/src/Mirza/SupplyChain/Types.hs +++ b/projects/or_scs/src/Mirza/SupplyChain/Types.hs @@ -34,7 +34,6 @@ import Control.Lens hiding ((.=)) import GHC.Generics (Generic) import Data.Aeson -import Data.Aeson.Types import qualified Data.ByteString as BS import Data.List.NonEmpty (NonEmpty) import Data.Pool as Pool @@ -166,25 +165,6 @@ instance ToJSON EventInfo where instance ToSchema EventInfo --- ***************************************************************************** --- Health Types --- ***************************************************************************** - -successHealthResponseText :: Text -successHealthResponseText = "Status OK" - -data HealthResponse = HealthResponse - deriving (Show, Eq, Read, Generic) -instance ToSchema HealthResponse -instance ToJSON HealthResponse where - toJSON _ = toJSON successHealthResponseText -instance FromJSON HealthResponse where - parseJSON (String value) - | value == successHealthResponseText = pure HealthResponse - | otherwise = fail "Invalid health response string." - parseJSON value = typeMismatch "HealthResponse" value - - -- ***************************************************************************** -- Error Types -- *****************************************************************************