mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
add published-at to registry response
This commit is contained in:
@@ -25,8 +25,10 @@ import Startlude (
|
||||
(&),
|
||||
(.),
|
||||
(<$>),
|
||||
UTCTime,
|
||||
)
|
||||
import Yesod
|
||||
import Data.Time.Format.ISO8601 (iso8601Show)
|
||||
|
||||
|
||||
dataUrl :: (ContentType, ByteString) -> Text
|
||||
@@ -48,6 +50,7 @@ data PackageRes = PackageRes
|
||||
, packageResLicense :: !Text
|
||||
, packageResVersions :: !(NonEmpty Version)
|
||||
, packageResDependencies :: !(HashMap PkgId DependencyRes)
|
||||
, packageResPublishedAt :: !UTCTime
|
||||
}
|
||||
deriving (Show, Generic)
|
||||
|
||||
@@ -66,6 +69,7 @@ instance ApiResponse PackageRes where
|
||||
, "categories" .= packageResCategories
|
||||
, "versions" .= packageResVersions
|
||||
, "dependency-metadata" .= (apiEncode v <$> packageResDependencies)
|
||||
, "published-at" .= (iso8601Show packageResPublishedAt)
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ import Startlude (
|
||||
(<&>),
|
||||
(<>),
|
||||
(=<<),
|
||||
liftA2,
|
||||
)
|
||||
import UnliftIO (Concurrently (..), mapConcurrently)
|
||||
import Yesod (
|
||||
@@ -92,6 +93,7 @@ import Yesod (
|
||||
sendResponseStatus,
|
||||
)
|
||||
import Yesod.Core (logWarn)
|
||||
import Data.List.NonEmpty (head)
|
||||
|
||||
|
||||
data PackageReq = PackageReq
|
||||
@@ -230,6 +232,7 @@ constructPackageListApiRes PackageMetadata{..} dependencies = do
|
||||
, packageResLicense = basicRender $ LicenseR V0 pkgId
|
||||
, packageResVersions = versionRecordNumber <$> pkgVersions
|
||||
, packageResDependencies = dependencies
|
||||
, packageResPublishedAt = ((liftA2 fromMaybe) versionRecordCreatedAt versionRecordUpdatedAt) (head pkgVersions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user