From e7e1305b6a2024c4500d1c5ff84a2fca2522dbea Mon Sep 17 00:00:00 2001 From: nek0 Date: Sun, 24 Jul 2022 23:11:47 +0200 Subject: [PATCH] make it work --- app/Main.hs | 5 +++-- mateamt.cabal | 1 + src/API.hs | 6 ++++++ src/Control.hs | 1 + src/Types/Settings.hs | 14 +++++++++++++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index edc6ceb..09f642d 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -57,10 +57,8 @@ import AppTypes import Types import Control import Janitor --- import Middleware import Paths_mateamt (version) -import Control.Monad.Except (runExceptT) main :: IO () main = do @@ -218,6 +216,9 @@ thisApi = roleAssociationSubmit :<|> roleAssociationDelete :<|> + getSettings :<|> + Control.updateSettings :<|> + metaGet mateSwagger :: OA.OpenApi diff --git a/mateamt.cabal b/mateamt.cabal index 23470e9..d0b3fe6 100644 --- a/mateamt.cabal +++ b/mateamt.cabal @@ -65,6 +65,7 @@ library Control.Journal Control.Meta Control.Avatar + Control.Settings Classes.DatabaseRepresentation Classes.ToDatabase Classes.FromDatabase diff --git a/src/API.hs b/src/API.hs index 8dd7482..b078348 100644 --- a/src/API.hs +++ b/src/API.hs @@ -138,6 +138,9 @@ roleAssociationListLink :: Link roleAssociationSubmitLink :: Link roleAssociationDeleteLink :: Link +settingsGetLink :: Link +settingsUpdateLnk :: Link + metaGetLink :: Link ( authGetLink :<|> @@ -180,5 +183,8 @@ metaGetLink :: Link roleAssociationSubmitLink :<|> roleAssociationDeleteLink :<|> + settingsGetLink :<|> + settingsUpdateLnk :<|> + metaGetLink ) = allLinks (Proxy :: Proxy MateAPI) diff --git a/src/Control.hs b/src/Control.hs index 633a830..ed0f00b 100644 --- a/src/Control.hs +++ b/src/Control.hs @@ -10,3 +10,4 @@ import Control.Product as C import Control.Avatar as C import Control.Role as C import Control.Meta as C +import Control.Settings as C diff --git a/src/Types/Settings.hs b/src/Types/Settings.hs index 4472fc7..bc6b1c7 100644 --- a/src/Types/Settings.hs +++ b/src/Types/Settings.hs @@ -1,7 +1,13 @@ {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE DeriveGeneric #-} module Types.Settings where +import Data.Aeson + import qualified Data.Text as T +import Data.OpenApi (ToSchema) + +import GHC.Generics -- internal imports @@ -11,7 +17,7 @@ data Settings = Settings { settingsBlockRegistration :: Bool , settingsImprintText :: Maybe T.Text } - deriving (Show) + deriving (Show, Generic) instance DatabaseRepresentation Settings where @@ -24,3 +30,9 @@ instance ToDatabase Settings where instance FromDatabase Settings where fromDatabase (reg, imprint) = Settings reg imprint + +instance FromJSON Settings + +instance ToJSON Settings + +instance ToSchema Settings