From 8e3a7bf1cb83bbb6e3dcd54308eefa52a29cd679 Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 3 Jun 2016 20:27:16 +0200 Subject: Migrate to elm 0.17 --- src/server/Main.hs | 61 ++++++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'src/server/Main.hs') diff --git a/src/server/Main.hs b/src/server/Main.hs index 0642288..5524ba7 100644 --- a/src/server/Main.hs +++ b/src/server/Main.hs @@ -22,7 +22,6 @@ import Controller.Income import Model.Database (runMigrations) import Model.Frequency -import Conf (Conf) import qualified Conf main :: IO () @@ -38,9 +37,7 @@ main = do middleware $ staticPolicy (noDots >-> addBase "public") - api conf - - notFound $ + get "/" $ ( do signInToken <- param "signInToken" :: ActionM Text status ok200 @@ -50,45 +47,41 @@ main = do getIndex conf Nothing ) -api :: Conf -> ScottyM () -api conf = do - -- Sign - - post "/api/signIn" $ do - email <- param "email" :: ActionM Text - signIn conf email + post "/signIn" $ do + email <- param "email" :: ActionM Text + signIn conf email - post "/api/signOut" (signOut conf) + post "/signOut" (signOut conf) - -- Users + -- Users - get "/api/users" getUsers + get "/users" getUsers - get "/api/whoAmI" whoAmI + get "/whoAmI" whoAmI - -- Incomes + -- Incomes - get "/api/incomes" getIncomes + get "/incomes" getIncomes - post "/api/income" $ do - creation <- param "creation" :: ActionM Int - amount <- param "amount" :: ActionM Int - addIncome (posixSecondsToUTCTime $ (fromIntegral creation) / 1000) amount + post "/income" $ do + creation <- param "creation" :: ActionM Int + amount <- param "amount" :: ActionM Int + addIncome (posixSecondsToUTCTime $ (fromIntegral creation) / 1000) amount - delete "/api/income/delete" $ do - incomeId <- param "id" :: ActionM Text - deleteOwnIncome incomeId + delete "/income" $ do + incomeId <- param "id" :: ActionM Text + deleteOwnIncome incomeId - -- Payments + -- Payments - get "/api/payments" getPayments + get "/payments" getPayments - post "/api/payment/add" $ do - name <- param "name" :: ActionM Text - cost <- param "cost" :: ActionM Text - frequency <- param "frequency" :: ActionM Frequency - createPayment name cost frequency + post "/payment/add" $ do + name <- param "name" :: ActionM Text + cost <- param "cost" :: ActionM Text + frequency <- param "frequency" :: ActionM Frequency + createPayment name cost frequency - post "/api/payment/delete" $ do - paymentId <- param "id" :: ActionM Text - deleteOwnPayment paymentId + delete "/payment" $ do + paymentId <- param "id" :: ActionM Text + deleteOwnPayment paymentId -- cgit v1.2.3