From e66534eefb5979c1ec5e0a28e9c29969ae2c9884 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Sun, 13 Oct 2024 11:55:20 +0200 Subject: improve REST API --- backend/lib/ACMS/API/REST/Collection.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'backend/lib/ACMS/API/REST/Collection.hs') diff --git a/backend/lib/ACMS/API/REST/Collection.hs b/backend/lib/ACMS/API/REST/Collection.hs index 3ca8ffd..b3faf19 100644 --- a/backend/lib/ACMS/API/REST/Collection.hs +++ b/backend/lib/ACMS/API/REST/Collection.hs @@ -11,12 +11,10 @@ import Data.Maybe import JavaScript.Web.XMLHttpRequest import Miso.String qualified as J #endif -import Collection import ACMS.API.REST (APIMonad, fetch, restRequest) +import Collection import Data.Aeson qualified as A import Data.Function ((&)) -import Debug.Trace -import Miso.String (MisoString) import Text.Printf (printf) list :: (APIMonad m) => Collection -> m [A.Object] @@ -25,7 +23,7 @@ list c = & fetch >>= A.throwDecode -read :: (APIMonad m) => CollectionItem -> m [A.Object] +read :: (APIMonad m) => CollectionItem -> m (Maybe A.Object) read ci = restRequest (printf "/collection/%s/%s" ci.collection.name ci.itemFileName) & fetch @@ -47,7 +45,7 @@ create c o = do & fetch >>= A.throwDecode -delete :: (APIMonad m) => CollectionItem -> m [A.Object] +delete :: (APIMonad m) => CollectionItem -> m A.Object delete ci = restRequest (printf "/collection/%s/%s" ci.collection.name ci.itemFileName) & setRequestMethod "DELETE" -- cgit v1.2.3