mirror of
https://github.com/Start9Labs/registry.git
synced 2026-04-01 04:33:39 +00:00
streaming output works
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
module Handler.Types.Apps where
|
||||
|
||||
import Startlude
|
||||
|
||||
import Data.Aeson
|
||||
import Yesod.Core.Content
|
||||
|
||||
import Lib.Types.StoreApp
|
||||
|
||||
newtype AvailableAppsRes = AvailableAppsRes
|
||||
{ availableApps :: [StoreApp]
|
||||
} deriving (Eq, Show)
|
||||
instance ToJSON AvailableAppsRes where
|
||||
toJSON = toJSON . availableApps
|
||||
instance ToTypedContent AvailableAppsRes where
|
||||
toTypedContent = toTypedContent . toJSON
|
||||
instance ToContent AvailableAppsRes where
|
||||
toContent = toContent . toJSON
|
||||
@@ -1,23 +0,0 @@
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
module Handler.Types.Register where
|
||||
|
||||
import Startlude
|
||||
|
||||
import Control.Monad.Fail
|
||||
import Data.Aeson
|
||||
import Data.ByteArray.Encoding
|
||||
import Data.ByteArray.Sized
|
||||
|
||||
data RegisterReq = RegisterReq
|
||||
{ registerProductKey :: Text
|
||||
, registerPubKey :: SizedByteArray 33 ByteString
|
||||
} deriving (Eq, Show)
|
||||
instance FromJSON RegisterReq where
|
||||
parseJSON = withObject "Register Request" $ \o -> do
|
||||
registerProductKey <- o .: "productKey"
|
||||
registerPubKey <- o .: "pubKey" >>= \t ->
|
||||
case sizedByteArray <=< hush . convertFromBase Base16 $ encodeUtf8 t of
|
||||
Nothing -> fail "Invalid Hex Encoded Public Key"
|
||||
Just x -> pure x
|
||||
pure RegisterReq{..}
|
||||
@@ -1,20 +1,31 @@
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
module Handler.Types.Status where
|
||||
|
||||
import Startlude
|
||||
|
||||
import Data.Aeson
|
||||
import Data.Text
|
||||
import Yesod.Core.Content
|
||||
|
||||
import Lib.Types.Semver
|
||||
import Lib.Types.StoreApp
|
||||
|
||||
newtype AppVersionRes = AppVersionRes
|
||||
{ unAppVersionRes :: AppVersion } deriving (Eq, Show)
|
||||
newtype AppVersionRes = AppVersionRes { unAppVersionRes ::AppVersion } deriving (Eq, Show)
|
||||
instance ToJSON AppVersionRes where
|
||||
toJSON AppVersionRes{unAppVersionRes} = object ["version" .= unAppVersionRes]
|
||||
toJSON AppVersionRes{ unAppVersionRes } = object ["version" .= unAppVersionRes]
|
||||
|
||||
instance ToContent AppVersionRes where
|
||||
toContent = toContent . toJSON
|
||||
instance ToTypedContent AppVersionRes where
|
||||
toTypedContent = toTypedContent . toJSON
|
||||
|
||||
-- Ugh
|
||||
instance ToContent (Maybe AppVersionRes) where
|
||||
toContent = toContent . toJSON
|
||||
instance ToTypedContent (Maybe AppVersionRes) where
|
||||
toTypedContent = toTypedContent . toJSON
|
||||
|
||||
querySpec :: Maybe Text -> Maybe AppVersionSpecification
|
||||
querySpec = (readMaybe . toS =<<)
|
||||
|
||||
querySpecD :: AppVersionSpecification -> Maybe Text -> AppVersionSpecification
|
||||
querySpecD defaultSpec = fromMaybe defaultSpec . querySpec
|
||||
|
||||
Reference in New Issue
Block a user