snix/src/API.hs
William Carroll 6d9e76313d Partially support DELETE /trips
Allow a user to delete a trip entry from the Trips table using the Primary
Key. While this type-checks and compiles, it doesn't appear to be working as
intended. Perhaps I should use an auto-incrementing integer as the Primary
Key. I'm not sure how I want to handle this, so I'm punting for now.
2020-07-28 10:14:33 +01:00

28 lines
873 B
Haskell

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
--------------------------------------------------------------------------------
module API where
--------------------------------------------------------------------------------
import Data.Text
import Servant.API
import qualified Types as T
--------------------------------------------------------------------------------
type API = "user"
:> ReqBody '[JSON] T.Account
:> Post '[JSON] (Maybe T.Session)
:<|> "user"
:> Capture "name" Text
:> Get '[JSON] (Maybe T.Account)
-- Create
:<|> "trips"
:> ReqBody '[JSON] T.Trip
:> Post '[JSON] NoContent
-- Read
:<|> "trips"
:> Get '[JSON] [T.Trip]
-- Delete
:<|> "trips"
:> ReqBody '[JSON] T.TripPK
:> Delete '[JSON] NoContent