mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
fix routes
This commit is contained in:
committed by
Keagan McClelland
parent
99dba0e273
commit
aa88306ee1
@@ -1,16 +1,19 @@
|
|||||||
|
|
||||||
!/package/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec}
|
!/package/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec}
|
||||||
/marketplace/package/data CategoriesR GET -- get all marketplace categories
|
/package/data CategoriesR GET -- get all marketplace categories
|
||||||
/marketplace/package/index PackageListR GET -- filter marketplace services by various query params
|
/package/index PackageListR GET -- filter marketplace services by various query params
|
||||||
/eos EosR GET -- get eos information
|
/eos/latest EosR GET -- get eos information
|
||||||
/marketplace/latest-version VersionLatestR GET -- get latest version of apps in query param id
|
/latest-version VersionLatestR GET -- get latest version of apps in query param id
|
||||||
/package/manifest/#AppIdentifier AppManifestR GET -- get app manifest from appmgr -- ?version={semver-spec}
|
/package/manifest/#AppIdentifier AppManifestR GET -- get app manifest from appmgr -- ?version={semver-spec}
|
||||||
/marketplace/package/release-notes getReleaseNotesR GET -- get release notes for package - expects query param of id=<pacakge-id>
|
/marketplace/package/release-notes ReleaseNotesR GET -- get release notes for package - expects query param of id=<pacakge-id>
|
||||||
|
/icons/#PNG IconsR GET -- get icons - expects ?version=<emver>
|
||||||
|
|
||||||
|
-- TODO confirm needed
|
||||||
|
/package/config/#AppIdentifier AppConfigR GET -- get app config from appmgr -- ?spec={semver-spec}
|
||||||
|
/package/version/#Text VersionAppR GET -- get most recent appId version
|
||||||
|
|
||||||
|
|
||||||
-- TODO deprecate
|
-- TODO deprecate
|
||||||
!/sys/#SYS_EXTENSIONLESS SysR GET -- get most recent sys app -- ?spec={semver-spec}
|
!/sys/#SYS_EXTENSIONLESS SysR GET -- get most recent sys app -- ?spec={semver-spec}
|
||||||
/version VersionR GET
|
/version VersionR GET
|
||||||
/icons/#PNG IconsR GET -- get icons
|
|
||||||
/sys/version/#Text VersionSysR GET -- get most recent sys app version
|
/sys/version/#Text VersionSysR GET -- get most recent sys app version
|
||||||
/package/config/#AppIdentifier AppConfigR GET -- get app config from appmgr -- ?spec={semver-spec}
|
|
||||||
/package/version/#Text VersionAppR GET -- get most recent appId version
|
|
||||||
@@ -7,7 +7,7 @@ module Handler.Icons where
|
|||||||
import Startlude hiding (Handler)
|
import Startlude hiding (Handler)
|
||||||
|
|
||||||
import Data.Conduit
|
import Data.Conduit
|
||||||
import qualified Data.Conduit.Binary as CB
|
import qualified Data.Conduit.Combinators as CB
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import Yesod.Core
|
import Yesod.Core
|
||||||
|
|
||||||
@@ -15,44 +15,47 @@ import Foundation
|
|||||||
import Lib.Registry
|
import Lib.Registry
|
||||||
import Settings
|
import Settings
|
||||||
import System.FilePath ((</>))
|
import System.FilePath ((</>))
|
||||||
|
import Util.Shared
|
||||||
|
import Lib.External.AppMgr
|
||||||
|
import Lib.Error
|
||||||
|
import qualified Data.ByteString.Lazy as BS
|
||||||
|
|
||||||
getIconsR :: Extension "png" -> Handler TypedContent
|
getIconsR :: Extension "png" -> Handler TypedContent
|
||||||
getIconsR ext = do
|
getIconsR ext = do
|
||||||
-- @TODO switch to getting from service directory
|
(appsDir, appMgrDir) <- getsYesod $ ((</> "apps") . resourcesDir &&& staticBinDir) . appSettings
|
||||||
AppSettings{..} <- appSettings <$> getYesod
|
spec <- getVersionFromQuery appsDir ext >>= \case
|
||||||
mPng <- liftIO $ getVersionedFileFromDir (resourcesDir </> "icons") ext
|
|
||||||
case mPng of
|
|
||||||
Nothing -> notFound
|
Nothing -> notFound
|
||||||
Just pngPath -> do
|
Just v -> pure v
|
||||||
putStrLn @Text $ show pngPath
|
servicePath <- liftIO $ getVersionedFileFromDir (appsDir </> show spec) ext spec
|
||||||
exists <- liftIO $ doesFileExist pngPath
|
case servicePath of
|
||||||
if exists
|
Nothing -> notFound
|
||||||
then respondSource typePlain $ CB.sourceFile pngPath .| awaitForever sendChunkBS
|
Just p -> do
|
||||||
else notFound
|
icon <- handleS9ErrT $ getIcon appMgrDir p ext
|
||||||
|
respondSource typePlain $ CB.sourceLazy (BS.fromStrict icon) .| awaitForever sendChunkBS
|
||||||
|
|
||||||
getLicenseR :: Extension "" -> Handler TypedContent
|
-- getLicenseR :: Extension "" -> Handler TypedContent
|
||||||
getLicenseR ext = do
|
-- getLicenseR ext = do
|
||||||
AppSettings{..} <- appSettings <$> getYesod
|
-- AppSettings{..} <- appSettings <$> getYesod
|
||||||
mPng <- liftIO $ getUnversionedFileFromDir (resourcesDir </> "icons") ext
|
-- mPng <- liftIO $ getUnversionedFileFromDir (resourcesDir </> "icons") ext
|
||||||
case mPng of
|
-- case mPng of
|
||||||
Nothing -> notFound
|
-- Nothing -> notFound
|
||||||
Just pngPath -> do
|
-- Just pngPath -> do
|
||||||
putStrLn @Text $ show pngPath
|
-- putStrLn @Text $ show pngPath
|
||||||
exists <- liftIO $ doesFileExist pngPath
|
-- exists <- liftIO $ doesFileExist pngPath
|
||||||
if exists
|
-- if exists
|
||||||
then respondSource typePlain $ CB.sourceFile pngPath .| awaitForever sendChunkBS
|
-- then respondSource typePlain $ CB.sourceFile pngPath .| awaitForever sendChunkBS
|
||||||
else notFound
|
-- else notFound
|
||||||
|
|
||||||
getMarkdownR :: Extension "md" -> Handler TypedContent
|
-- getMarkdownR :: Extension "md" -> Handler TypedContent
|
||||||
getMarkdownR ext = do
|
-- getMarkdownR ext = do
|
||||||
-- @TODO switch to getting from service directory
|
-- -- @TODO switch to getting from service directory
|
||||||
AppSettings{..} <- appSettings <$> getYesod
|
-- AppSettings{..} <- appSettings <$> getYesod
|
||||||
mPng <- liftIO $ getUnversionedFileFromDir (resourcesDir </> "icons") ext
|
-- mPng <- liftIO $ getUnversionedFileFromDir (resourcesDir </> "icons") ext
|
||||||
case mPng of
|
-- case mPng of
|
||||||
Nothing -> notFound
|
-- Nothing -> notFound
|
||||||
Just pngPath -> do
|
-- Just pngPath -> do
|
||||||
putStrLn @Text $ show pngPath
|
-- putStrLn @Text $ show pngPath
|
||||||
exists <- liftIO $ doesFileExist pngPath
|
-- exists <- liftIO $ doesFileExist pngPath
|
||||||
if exists
|
-- if exists
|
||||||
then respondSource typePlain $ CB.sourceFile pngPath .| awaitForever sendChunkBS
|
-- then respondSource typePlain $ CB.sourceFile pngPath .| awaitForever sendChunkBS
|
||||||
else notFound
|
-- else notFound
|
||||||
@@ -59,6 +59,10 @@ newtype ReleaseNotes = ReleaseNotes { unReleaseNotes :: HM.HashMap Version Text
|
|||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
instance ToJSON ReleaseNotes where
|
instance ToJSON ReleaseNotes where
|
||||||
toJSON ReleaseNotes { .. } = object [ t .= v | (k,v) <- HM.toList unReleaseNotes, let (String t) = toJSON k ]
|
toJSON ReleaseNotes { .. } = object [ t .= v | (k,v) <- HM.toList unReleaseNotes, let (String t) = toJSON k ]
|
||||||
|
instance ToContent ReleaseNotes where
|
||||||
|
toContent = toContent . toJSON
|
||||||
|
instance ToTypedContent ReleaseNotes where
|
||||||
|
toTypedContent = toTypedContent . toJSON
|
||||||
instance ToJSON ServiceRes where
|
instance ToJSON ServiceRes where
|
||||||
toJSON ServiceRes {..} = object
|
toJSON ServiceRes {..} = object
|
||||||
[ "icon" .= serviceResIcon
|
[ "icon" .= serviceResIcon
|
||||||
|
|||||||
Reference in New Issue
Block a user