mirror of
https://github.com/aelve/guide.git
synced 2024-12-25 13:51:45 +03:00
Fix imports (#199)
This commit is contained in:
parent
28eb2ee6f2
commit
f1fed71b13
@ -46,6 +46,9 @@ library
|
||||
exposed-modules:
|
||||
Guide.App
|
||||
Guide.Api
|
||||
Guide.Api.Methods
|
||||
Guide.Api.Server
|
||||
Guide.Api.Types
|
||||
Guide.Main
|
||||
Guide.ServerStuff
|
||||
Guide.Session
|
||||
|
@ -1,7 +1,7 @@
|
||||
module Guide.Api
|
||||
( Guide.Api.Methods
|
||||
, Guide.Api.Server
|
||||
, Guide.Api.Types
|
||||
( module Guide.Api.Methods
|
||||
, module Guide.Api.Server
|
||||
, module Guide.Api.Types
|
||||
) where
|
||||
|
||||
import Guide.Api.Methods
|
||||
|
@ -11,23 +11,20 @@ module Guide.Api.Methods
|
||||
|
||||
import Imports
|
||||
|
||||
import Data.Aeson
|
||||
import Servant
|
||||
import Servant.Generic
|
||||
import Network.Wai.Handler.Warp (run)
|
||||
import Data.Acid as Acid
|
||||
|
||||
import Guide.Types
|
||||
import Guide.State
|
||||
import Guide.Utils (Uid)
|
||||
import Guide.Api.Types (toCategoryInfo, toCCategoryDetail)
|
||||
import Guide.Api.Types (ApiError(..), CategoryInfo, CCategoryDetail, toCategoryInfo, toCCategoryDetail)
|
||||
|
||||
getCategories :: DB -> Handler [CategoryInfo]
|
||||
getCategories db = do
|
||||
liftIO (Acid.query db GetCategories) <&> \xs ->
|
||||
map toCategoryInfo xs
|
||||
|
||||
getCategory :: DB -> Uid Category -> Handler (Either ApiError CCategory)
|
||||
getCategory :: DB -> Uid Category -> Handler (Either ApiError CCategoryDetail)
|
||||
getCategory db catId =
|
||||
liftIO (Acid.query db (GetCategoryMaybe catId)) <&> \case
|
||||
Nothing -> Left (ApiError "category not found")
|
||||
|
@ -12,15 +12,16 @@ module Guide.Api.Server
|
||||
|
||||
import Imports
|
||||
|
||||
import Data.Aeson
|
||||
import Data.Acid as Acid
|
||||
import Servant
|
||||
import Servant.Generic
|
||||
import Network.Wai.Handler.Warp (run)
|
||||
-- putStrLn that works well with concurrency
|
||||
import Say (say)
|
||||
|
||||
import Guide.Types
|
||||
import Guide.State
|
||||
import Guide.Api.Types (Api, Site(..))
|
||||
import Guide.Api.Methods (getCategories, getCategory)
|
||||
|
||||
apiServer :: DB -> Site AsServer
|
||||
apiServer db = Site {
|
||||
|
@ -7,7 +7,8 @@
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
module Guide.Api.Types
|
||||
( ApiError(..)
|
||||
( Api
|
||||
, ApiError(..)
|
||||
, CategoryInfo(..)
|
||||
, CCategoryDetail(..)
|
||||
, CUid(..)
|
||||
@ -50,10 +51,11 @@ data Site route = Site
|
||||
-- | Details of a single category (and items in it, etc)
|
||||
, _getCategory :: route :-
|
||||
"category" :> Capture "id" (Uid Category)
|
||||
:> Get '[JSON] (Either ApiError Category)
|
||||
:> Get '[JSON] (Either ApiError CCategoryDetail)
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
type Api = ToServant (Site AsApi)
|
||||
----------------------------------------------------------------------------
|
||||
-- Client types
|
||||
----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user