mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-30 11:51:57 +00:00
rename apps endpoints to package and add header to addl endpoint
This commit is contained in:
committed by
Keagan McClelland
parent
1c069ca6f8
commit
09e188e9d8
@@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
/version VersionR GET
|
/version VersionR GET
|
||||||
|
|
||||||
/apps/version/#Text VersionAppR GET -- get most recent appId version
|
/package/version/#Text VersionAppR GET -- get most recent appId version
|
||||||
/sys/version/#Text VersionSysR GET -- get most recent sys app version
|
/sys/version/#Text VersionSysR GET -- get most recent sys app version
|
||||||
|
|
||||||
/icons/#PNG IconsR GET -- get icons
|
/icons/#PNG IconsR GET -- get icons
|
||||||
!/apps/#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}
|
||||||
|
|
||||||
/sys/status SystemStatusR GET -- get system update status and version
|
/sys/status SystemStatusR GET -- get system update status and version
|
||||||
!/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}
|
||||||
|
|||||||
@@ -112,12 +112,16 @@ getApp rootDir ext@(Extension appId) = do
|
|||||||
putStrLn $ "valid appversion for " <> (show ext :: String) <> ": " <> show appVersions
|
putStrLn $ "valid appversion for " <> (show ext :: String) <> ": " <> show appVersions
|
||||||
let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions
|
let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions
|
||||||
let best = fst . getMaxVersion <$> foldMap (Just . MaxVersion . (, fst . unRegisteredAppVersion)) satisfactory
|
let best = fst . getMaxVersion <$> foldMap (Just . MaxVersion . (, fst . unRegisteredAppVersion)) satisfactory
|
||||||
|
(appsDir, appMgrDir) <- getsYesod $ ((</> "apps") . resourcesDir &&& staticBinDir) . appSettings
|
||||||
case best of
|
case best of
|
||||||
Nothing -> notFound
|
Nothing -> notFound
|
||||||
Just (RegisteredAppVersion (appVersion, filePath)) -> do
|
Just (RegisteredAppVersion (appVersion, filePath)) -> do
|
||||||
exists' <- liftIO $ doesFileExist filePath >>= \case
|
exists' <- liftIO $ doesFileExist filePath >>= \case
|
||||||
True -> pure Existent
|
True -> pure Existent
|
||||||
False -> pure NonExistent
|
False -> pure NonExistent
|
||||||
|
let appDir = (<> "/") . (</> show appVersion) . (</> toS appId) $ appsDir
|
||||||
|
let appExt = Extension (toS appId) :: Extension "s9pk"
|
||||||
|
addPackageHeader appMgrDir appDir appExt
|
||||||
determineEvent exists' (extension ext) filePath appVersion
|
determineEvent exists' (extension ext) filePath appVersion
|
||||||
where
|
where
|
||||||
determineEvent :: FileExistence -> String -> FilePath -> Version -> HandlerFor RegistryCtx TypedContent
|
determineEvent :: FileExistence -> String -> FilePath -> Version -> HandlerFor RegistryCtx TypedContent
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ getServiceR = do
|
|||||||
-- @TODO uncomment when sdk icon working
|
-- @TODO uncomment when sdk icon working
|
||||||
-- icon <- decodeIcon appMgrDir depPath appExt
|
-- icon <- decodeIcon appMgrDir depPath appExt
|
||||||
let icon = [i|https://#{domain}/icons/#{appId}.png|]
|
let icon = [i|https://#{domain}/icons/#{appId}.png|]
|
||||||
-- addPackageHeader appMgrDir appDir appExt
|
addPackageHeader appMgrDir appDir appExt
|
||||||
pure $ ServiceRes
|
pure $ ServiceRes
|
||||||
{ serviceResIcon = icon
|
{ serviceResIcon = icon
|
||||||
, serviceResManifest = manifest -- TypedContent "application/json" (toContent manifest)
|
, serviceResManifest = manifest -- TypedContent "application/json" (toContent manifest)
|
||||||
|
|||||||
@@ -27,8 +27,14 @@ getVersionR = do
|
|||||||
|
|
||||||
getVersionAppR :: Text -> Handler (Maybe AppVersionRes)
|
getVersionAppR :: Text -> Handler (Maybe AppVersionRes)
|
||||||
getVersionAppR appId = do
|
getVersionAppR appId = do
|
||||||
appsDir <- (</> "apps") . resourcesDir . appSettings <$> getYesod
|
(appsDir, appMgrDir) <- getsYesod $ ((</> "apps") . resourcesDir &&& staticBinDir) . appSettings
|
||||||
getVersionWSpec appsDir appExt
|
res <- getVersionWSpec appsDir appExt
|
||||||
|
case res of
|
||||||
|
Nothing -> pure res
|
||||||
|
Just r -> do
|
||||||
|
let appDir = (<> "/") . (</> (show $ appVersionVersion r)) . (</> toS appId) $ appsDir
|
||||||
|
addPackageHeader appMgrDir appDir appExt
|
||||||
|
pure res
|
||||||
where appExt = Extension (toS appId) :: Extension "s9pk"
|
where appExt = Extension (toS appId) :: Extension "s9pk"
|
||||||
|
|
||||||
-- @TODO update to using db record
|
-- @TODO update to using db record
|
||||||
|
|||||||
Reference in New Issue
Block a user