Skip to content

Commit

Permalink
Bump versions, module consistency, remove unused comment (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
expede authored May 10, 2021
1 parent 59d04c6 commit c31324a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
module Fission.App.Types
( module Fission.App.Name
, Payload(..)
) where
module Fission.Web.API.App.Index.Payload.Types (Payload(..)) where

import Data.Swagger hiding (URL, url)
import Data.Swagger hiding (URL, url)

import Fission.Prelude

import Fission.App.Name
import Fission.URL


data Payload = Payload
{ urls :: [URL]
, insertedAt :: UTCTime
, modifiedAt :: UTCTime
}
-- What about deriving Json of normal data?
-- deriving (Eq, Generic, Show, ToJSON)
deriving (Eq, Show)



instance FromJSON Payload where
parseJSON = withObject "Payload" \obj -> do
urls <- obj .: "urls"
Expand Down Expand Up @@ -53,12 +44,15 @@ instance ToSchema Payload where
|> required .~ ["username", "email"]
|> description ?~ "Properties for a registered application"
|> example ?~ toJSON Payload
{ urls = [ URL
(DomainName "fission.codes")
(Just $ Subdomain "my-cool-subdomain")
]
, insertedAt = fromSeconds 0
, modifiedAt = fromSeconds 20
{ urls = [url]
, insertedAt = fromSeconds 1620600000
, modifiedAt = fromSeconds 1620610000
}
|> NamedSchema (Just "Payload")
|> NamedSchema (Just "App Index Payload")
|> pure

where
url = URL
{ domainName = DomainName "fission.codes"
, subdomain = Just $ Subdomain "my-cool-subdomain"
}
10 changes: 6 additions & 4 deletions fission-web-api/library/Fission/Web/API/App/Index/Types.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module Fission.Web.API.App.Index.Types (Index) where

import Fission.App.Types
module Fission.Web.API.App.Index.Types
( Index
, module Fission.Web.API.App.Index.Payload.Types
) where

import Fission.Web.API.Prelude

import qualified Fission.Web.API.Auth.Types as Auth
import Fission.Web.API.App.Index.Payload.Types
import qualified Fission.Web.API.Auth.Types as Auth

type Index
= Summary "App index"
Expand Down
3 changes: 2 additions & 1 deletion fission-web-api/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fission-web-api
version: '1.2.0.0'
version: '1.3.0.0'
category: API
author:
- Brooklyn Zelenka
Expand Down Expand Up @@ -94,6 +94,7 @@ dependencies:
- cryptonite

## Data ##
- swagger2
- uuid

## Fission
Expand Down
22 changes: 17 additions & 5 deletions fission-web-server/library/Fission/Web/Server/Handler/App/Index.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Servant

import Fission.Prelude

import Fission.App.Types
import Fission.URL.Types

import Fission.Web.API.App.Index.Types
Expand All @@ -21,13 +20,26 @@ index :: (MonadDB t m, App.Retriever t, App.Domain.Retriever t) => ServerT Index
index Authorization {about = Entity userId _} = runDB do
apps <- App.ownedBy userId
appXDomains <- forM apps findDomains
let normalized = (\(k, v) -> (fromIntegral (fromSqlKey k), v)) <$> appXDomains
return (Map.fromList normalized)
return $ Map.fromList appXDomains

where
findDomains :: App.Domain.Retriever m => Entity App -> m (AppId, Payload)
findDomains :: App.Domain.Retriever m => Entity App -> m (Natural, Payload)
findDomains (Entity appId App {appInsertedAt, appModifiedAt}) = do
appDomains <- App.Domain.allForApp appId
return (appId, Payload (toURL <$> appDomains) appInsertedAt appModifiedAt)

let
natKey :: Natural
natKey = fromIntegral $ fromSqlKey appId

payload :: Payload
payload =
Payload
{ urls = toURL <$> appDomains
, insertedAt = appInsertedAt
, modifiedAt = appModifiedAt
}

return (natKey, payload)

toURL :: Entity AppDomain -> URL
toURL (Entity _ AppDomain {..}) = URL appDomainDomainName appDomainSubdomain
2 changes: 1 addition & 1 deletion fission-web-server/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fission-web-server
version: '2.13.2.0'
version: '2.14.0.0'
category: API
author:
- Brooklyn Zelenka
Expand Down

0 comments on commit c31324a

Please sign in to comment.