mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 10:21:51 +00:00
add marketplace description to info response
This commit is contained in:
@@ -36,6 +36,7 @@ tor-port: "_env:TOR_PORT:447"
|
||||
static-bin-dir: "_env:STATIC_BIN:/usr/local/bin/"
|
||||
error-log-root: "_env:ERROR_LOG_ROOT:/var/log/embassy-os/"
|
||||
marketplace-name: "_env:MARKETPLACE_NAME:CHANGE ME"
|
||||
marketplace-description: "_env:MARKETPLACE_NAME:IMA DESCRIPTION"
|
||||
|
||||
database:
|
||||
database: "_env:PG_DATABASE:start9_registry"
|
||||
|
||||
@@ -6,13 +6,14 @@ import Foundation (Handler, RegistryCtx (..))
|
||||
import Handler.Util (tickleMAU)
|
||||
import Model (Category (..), EntityField (..))
|
||||
import Settings (AppSettings (..))
|
||||
import Startlude (Generic, Show, Text, pure, ($), (.), (<$>))
|
||||
import Startlude (Generic, Show, Text, pure, ($), (.), (<$>), (&&&))
|
||||
import Yesod (ToContent (..), ToTypedContent (..), YesodPersist (runDB), getsYesod)
|
||||
import Yesod.Core.Types (JSONResponse (..))
|
||||
|
||||
|
||||
data InfoRes = InfoRes
|
||||
{ name :: !Text
|
||||
, description:: !Text
|
||||
, categories :: ![Text]
|
||||
}
|
||||
deriving (Show, Generic)
|
||||
@@ -25,11 +26,11 @@ instance ToTypedContent InfoRes where
|
||||
|
||||
getInfoR :: Handler (JSONResponse InfoRes)
|
||||
getInfoR = do
|
||||
name <- getsYesod $ marketplaceName . appSettings
|
||||
(name, description) <- getsYesod $ (marketplaceName &&& marketplaceDescription) . appSettings
|
||||
allCategories <- runDB $
|
||||
select $ do
|
||||
cats <- from $ table @Category
|
||||
orderBy [asc (cats ^. CategoryPriority)]
|
||||
pure cats
|
||||
tickleMAU
|
||||
pure $ JSONResponse $ InfoRes name $ categoryName . entityVal <$> allCategories
|
||||
pure $ JSONResponse $ InfoRes name description $ categoryName . entityVal <$> allCategories
|
||||
|
||||
@@ -85,6 +85,7 @@ data AppSettings = AppSettings
|
||||
, staticBinDir :: !FilePath
|
||||
, errorLogRoot :: !FilePath
|
||||
, marketplaceName :: !Text
|
||||
, marketplaceDescription :: !Text
|
||||
}
|
||||
instance Has PkgRepo AppSettings where
|
||||
extract = liftA2 PkgRepo ((</> "apps") . resourcesDir) staticBinDir
|
||||
@@ -113,14 +114,14 @@ instance FromJSON AppSettings where
|
||||
torPort <- o .: "tor-port"
|
||||
staticBinDir <- o .: "static-bin-dir"
|
||||
errorLogRoot <- o .: "error-log-root"
|
||||
marketplaceName <- o .: "marketplace-name"
|
||||
marketplaceDescription <- o .: "marketplace-description"
|
||||
|
||||
let sslKeyLocation = sslPath </> "key.pem"
|
||||
let sslCsrLocation = sslPath </> "certificate.csr"
|
||||
let sslCertLocation = sslPath </> "certificate.pem"
|
||||
let registryVersion = fromJust . parseMaybe parseJSON . String . toS . showVersion $ version
|
||||
|
||||
marketplaceName <- o .: "marketplace-name"
|
||||
|
||||
return AppSettings { .. }
|
||||
|
||||
-- | Raw bytes at compile time of @config/settings.yml@
|
||||
|
||||
Reference in New Issue
Block a user