list collections

This commit is contained in:
Alexander Foremny
2024-06-06 22:52:33 +02:00
parent b1a4822d59
commit 3add980b73
3 changed files with 32 additions and 12 deletions

View File

@@ -1,7 +1,8 @@
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
module Api
( fetchSchema,
( fetchCollections,
fetchSchema,
fetchSchemaVersion,
fetchPosts,
fetchPost,
@@ -28,14 +29,18 @@ import Safe
import Schema
import Version
fetchSchema :: JSM (Either String Schema)
fetchSchema =
A.eitherDecode <$> fetch (fromString "http://localhost:8081/posts.schema.json")
fetchCollections :: JSM (Either String [String])
fetchCollections =
A.eitherDecode <$> fetch (fromString "http://localhost:8081/collections")
fetchSchemaVersion :: JSM (Either String Version)
fetchSchemaVersion =
A.eitherDecode <$> fetch (fromString "http://localhost:8081/schemaVersion")
fetchSchema :: JSM (Either String Schema)
fetchSchema =
A.eitherDecode <$> fetch (fromString "http://localhost:8081/posts.schema.json")
fetchPosts :: JSM (Either String [A.Value])
fetchPosts =
A.eitherDecode