adds name to /package/data

This commit is contained in:
Keagan McClelland
2022-02-02 11:12:21 -07:00
parent 83ad920de4
commit 5b39717591
6 changed files with 17 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
!/package/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec}
/package/data CategoriesR GET -- get all marketplace categories
/package/data InfoR GET -- get all marketplace categories
/package/index PackageListR GET -- filter marketplace services by various query params
-- /package/updates
/eos/latest EosVersionR GET -- get eos information

View File

@@ -78,7 +78,6 @@ import Yesod.Core
import Yesod.Core.Types hiding ( Logger )
import Yesod.Default.Config2
import Control.Arrow ( (***) )
import Control.Lens
import Data.List ( lookup )
import Data.String.Interpolate.IsString

View File

@@ -129,13 +129,14 @@ import Yesod.Core ( MonadResource
import Yesod.Persist ( YesodDB )
import Yesod.Persist.Core ( YesodPersist(runDB) )
getCategoriesR :: Handler CategoryRes
getCategoriesR = do
getInfoR :: Handler InfoRes
getInfoR = do
name <- getsYesod $ marketplaceName . appSettings
allCategories <- runDB $ select $ do
cats <- from $ table @Category
orderBy [desc (cats ^. CategoryPriority)]
pure cats
pure $ CategoryRes $ categoryName . entityVal <$> allCategories
pure $ InfoRes name $ categoryName . entityVal <$> allCategories
getEosVersionR :: Handler EosRes
getEosVersionR = do

View File

@@ -19,13 +19,15 @@ import Yesod
type URL = Text
newtype CategoryRes = CategoryRes {
categories :: [CategoryTitle]
} deriving (Show, Generic)
instance ToJSON CategoryRes
instance ToContent CategoryRes where
data InfoRes = InfoRes
{ name :: Text
, categories :: [CategoryTitle]
}
deriving (Show, Generic)
instance ToJSON InfoRes
instance ToContent InfoRes where
toContent = toContent . toJSON
instance ToTypedContent CategoryRes where
instance ToTypedContent InfoRes where
toTypedContent = toTypedContent . toJSON
data PackageRes = PackageRes
{ packageResIcon :: URL

View File

@@ -56,6 +56,7 @@ data AppSettings = AppSettings
, torPort :: AppPort
, staticBinDir :: FilePath
, errorLogRoot :: FilePath
, marketplaceName :: Text
}
instance Has PkgRepo AppSettings where
extract = liftA2 PkgRepo ((</> "apps") . resourcesDir) staticBinDir
@@ -84,6 +85,8 @@ instance FromJSON AppSettings where
let sslCertLocation = sslPath </> "certificate.pem"
let registryVersion = fromJust . parseMaybe parseJSON . String . toS . showVersion $ version
marketplaceName <- o .:? "marketplace-name" .!= "Start9 Embassy Marketplace"
return AppSettings { .. }
-- | Raw bytes at compile time of @config/settings.yml@

View File

@@ -44,11 +44,7 @@ extra-deps:
- esqueleto-3.5.1.0
- monad-logger-extras-0.1.1.1
- wai-request-spec-0.10.2.4
- git: https://github.com/ProofOfKeags/wai
commit: 2eef8506c7eec67fa5c1be0e0470a38e277ab5d8
subdirs:
- warp
- warp-tls
- warp-3.3.19
# Override default flag values for local packages and extra-deps
# flags: {}