2020-07-24 20:00:29 +02:00
|
|
|
{-# LANGUAGE DataKinds #-}
|
2020-07-24 23:46:54 +02:00
|
|
|
{-# LANGUAGE TypeOperators #-}
|
2020-07-24 20:00:29 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
module API where
|
|
|
|
--------------------------------------------------------------------------------
|
2020-07-24 23:46:54 +02:00
|
|
|
import Data.Text
|
|
|
|
import Servant.API
|
2020-07-24 20:00:29 +02:00
|
|
|
|
2020-07-24 23:46:54 +02:00
|
|
|
import qualified Types as T
|
2020-07-24 20:00:29 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2020-07-28 11:57:15 +02:00
|
|
|
type API =
|
|
|
|
-- accounts: Create
|
|
|
|
"accounts"
|
2020-07-28 13:49:16 +02:00
|
|
|
:> ReqBody '[JSON] T.CreateAccountRequest
|
|
|
|
:> Post '[JSON] NoContent
|
2020-07-28 11:57:15 +02:00
|
|
|
-- accounts: Read
|
|
|
|
-- accounts: Update
|
|
|
|
-- accounts: Delete
|
|
|
|
:<|> "accounts"
|
|
|
|
:> QueryParam' '[Required] "username" Text
|
|
|
|
:> Delete '[JSON] NoContent
|
|
|
|
-- accounts: List
|
|
|
|
:<|> "accounts"
|
|
|
|
:> Get '[JSON] [T.User]
|
|
|
|
|
|
|
|
-- trips: Create
|
2020-07-28 11:14:33 +02:00
|
|
|
:<|> "trips"
|
2020-07-28 10:10:54 +02:00
|
|
|
:> ReqBody '[JSON] T.Trip
|
2020-07-28 11:12:25 +02:00
|
|
|
:> Post '[JSON] NoContent
|
2020-07-28 11:57:15 +02:00
|
|
|
-- trips: Read
|
|
|
|
-- trips: Update
|
|
|
|
-- trips: Delete
|
2020-07-28 11:14:33 +02:00
|
|
|
:<|> "trips"
|
|
|
|
:> ReqBody '[JSON] T.TripPK
|
|
|
|
:> Delete '[JSON] NoContent
|
2020-07-28 11:57:15 +02:00
|
|
|
-- trips: List
|
|
|
|
:<|> "trips"
|
|
|
|
:> Get '[JSON] [T.Trip]
|