From 869bab77e93e2a6c776a4b1fc35ef0fd5df22f5f Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 27 Mar 2016 17:36:33 +0200 Subject: Compute payers client side rather than server side --- src/server/Json.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/server/Json.hs') diff --git a/src/server/Json.hs b/src/server/Json.hs index a2f1ef5..408742a 100644 --- a/src/server/Json.hs +++ b/src/server/Json.hs @@ -1,7 +1,9 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE FlexibleContexts #-} module Json ( jsonObject + , jsonId ) where import Web.Scotty @@ -10,5 +12,13 @@ import qualified Data.Aeson.Types as Json import qualified Data.HashMap.Strict as M import Data.Text (Text) +import Database.Persist +import Database.Persist.Sqlite + +import Model.Database + jsonObject :: [(Text, Json.Value)] -> ActionM () jsonObject = json . Json.Object . M.fromList + +jsonId :: (ToBackendKey SqlBackend a) => Key a -> ActionM () +jsonId key = json . Json.Object . M.fromList $ [("id", Json.Number . fromIntegral . keyToInt64 $ key)] -- cgit v1.2.3