adds name to /package/data

This commit is contained in:
Keagan McClelland
2022-02-02 11:12:21 -07:00
parent 139ba20e2f
commit 0d7fab5789
6 changed files with 17 additions and 16 deletions

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