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