aboutsummaryrefslogtreecommitdiff
path: root/src/server/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Main.hs')
-rw-r--r--src/server/Main.hs61
1 files changed, 27 insertions, 34 deletions
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