finished api definitions and uses RealWorld.hs instead of Lib.hs as the entry point.

parent 9c4299b1
module Main where
import Protolude
import Lib
import RealWorld
import Protolude
main :: IO ()
main = someFunc
main = running
......@@ -16,11 +16,13 @@ cabal-version: >=1.10
library
hs-source-dirs: src
ghc-options: -Wall
exposed-modules: Lib
, Types
exposed-modules: Types
, Conf
, Model
, API.User
, API.Articles
, API.Profile
, API.Tags
, RealWorld
other-modules: Lib.Prelude
build-depends: base >= 4.7 && < 5
......
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
module API.Articles where
import Lib.Prelude
import Servant
import Servant.Auth.Server
import Types
import Model
import Conf
type ArticlesAPI =
"articles"
:> QueryParam "tag" Text
:> QueryParam "author" Text
:> QueryParam "favorited" Text
:> QueryParam "limit" Int64
:> QueryParam "offset" Int64
:> Get '[ JSON] ResponseMultiArticle
:<|> "articles"
:> "feed"
:> QueryParam "limit" Int64
:> QueryParam "offset" Int64
:> Get '[ JSON] ResponseMultiArticle
:<|> "articles"
:> Capture "slug" Text
:> Get '[ JSON] ResponseArticle
:<|> "articles"
:> ReqBody '[ JSON] RequestCreateArticle
:> Post '[ JSON] ResponseArticle
:<|> "articles"
:> Capture "slug" Text
:> DeleteNoContent '[ JSON] NoContent
:<|> "articles"
:> Capture "slug" Text
:> ReqBody '[ JSON] RequestUpdateArticle
:> Put '[ JSON] ResponseArticle
:<|> "articles"
:> Capture "slug" Text
:> "comments"
:> Get '[JSON] ResponseMultiComment
:<|> "articles"
:> Capture "slug" Text
:> "comments"
:> ReqBody '[ JSON] RequestComment
:> Post '[JSON] ResponseComment
:<|> "articles"
:> Capture "slug" Text
:> "comments"
:> Capture "id" Int64
:> DeleteNoContent '[ JSON] NoContent
:<|> "articles"
:> Capture "slug" Text
:> "favorite"
:> PostNoContent '[ JSON] NoContent
:<|> "articles"
:> Capture "slug" Text
:> "favorite"
:> DeleteNoContent '[ JSON] NoContent
articlesProxy :: Proxy ArticlesAPI
articlesProxy = Proxy
articlesApi :: MonadIO m => AuthResult User -> ServerT ArticlesAPI (CoachT m)
articlesApi authres = panic ""
articlesServer :: Configuration -> AuthResult User -> Server ArticlesAPI
articlesServer conf authres =
hoistServer articlesProxy (coachToHandler conf) (articlesApi authres)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module API.Profile where
import Lib.Prelude
import Servant
import Servant.Auth.Server
import Types
import Model
import Conf
type UserProfileAPI =
"profiles"
:> Capture "username" Text
:> Get '[ JSON] ResponseProfile
:<|> "profiles"
:> Capture "username" Text
:> "follow"
:> PostNoContent '[ JSON] NoContent
:<|> "profiles"
:> Capture "username" Text
:> "follow"
:> DeleteNoContent '[ JSON] NoContent
userProfileApi :: MonadIO m => AuthResult User -> ServerT UserProfileAPI (CoachT m)
userProfileApi authres = panic ""
userProfileProxy :: Proxy UserProfileAPI
userProfileProxy = Proxy
userProfileServer :: Configuration -> AuthResult User -> Server UserProfileAPI
userProfileServer conf authres =
hoistServer userProfileProxy (coachToHandler conf) (userProfileApi authres)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module API.Tags where
import Protolude
import Servant
import Types
import Conf
type TagsAPI = "tags" :> Get '[ JSON] ResponseTags
tagsApi :: MonadIO m => ServerT TagsAPI (CoachT m)
tagsApi = panic ""
tagsProxy :: Proxy TagsAPI
tagsProxy = Proxy
tagsServer :: Configuration -> Server TagsAPI
tagsServer conf = hoistServer tagsProxy (coachToHandler conf) tagsApi
module Lib
( someFunc
) where
import Lib.Prelude
someFunc :: IO ()
someFunc = putText "someFunc"
......@@ -19,10 +19,16 @@ import Conf
import Model
import API.User
import API.Articles
import API.Profile
import API.Tags
type ConduitAPI auth =
"api" :> (Servant.Auth.Server.Auth auth User :> UserInformationAPI)
"api" :> (Auth auth User :> UserInformationAPI)
:<|> "api" :> UserAdministrationAPI
:<|> "api" :> (Auth auth User :> UserProfileAPI)
:<|> "api" :> (Auth auth User :> ArticlesAPI)
:<|> "api" :> TagsAPI
:<|> Raw
conduitProxy :: Proxy (ConduitAPI '[JWT])
......@@ -32,6 +38,9 @@ conduitServer :: Configuration -> Server (ConduitAPI auth)
conduitServer conf =
userInformationServer conf
:<|> userAdministrationServer conf
:<|> userProfileServer conf
:<|> articlesServer conf
:<|> tagsServer conf
:<|> serveDirectoryFileServer "front"
connstring :: ByteString
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment