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