aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorJoris2016-03-28 17:51:14 +0200
committerJoris2016-03-28 17:51:14 +0200
commit166cd04e4b28770ede854dafc9ae30eae64102fe (patch)
tree2245a31243a165acc6f7355534da44cfd17e6038 /src/server
parentb0d80a5458d7ba4546e5f01f5b6398ea6d23f981 (diff)
downloadbudget-166cd04e4b28770ede854dafc9ae30eae64102fe.tar.gz
budget-166cd04e4b28770ede854dafc9ae30eae64102fe.tar.bz2
budget-166cd04e4b28770ede854dafc9ae30eae64102fe.zip
Create an empty but reachable user page
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Design/Header.hs2
-rw-r--r--src/server/Main.hs59
2 files changed, 35 insertions, 26 deletions
diff --git a/src/server/Design/Header.hs b/src/server/Design/Header.hs
index 8a348ad..a06a830 100644
--- a/src/server/Design/Header.hs
+++ b/src/server/Design/Header.hs
@@ -23,7 +23,7 @@ headerDesign =
marginBottom blockMarginBottom
position relative
- button ? do
+ ((".title" |> h1) <> ".user" <> ".icon") ? do
color C.white
backgroundColor C.red
hover & backgroundColor darkenedRed
diff --git a/src/server/Main.hs b/src/server/Main.hs
index 4f74f8e..e4ad9f6 100644
--- a/src/server/Main.hs
+++ b/src/server/Main.hs
@@ -20,6 +20,7 @@ import Controller.Income
import Model.Database (runMigrations)
import Model.Frequency
+import Conf (Conf)
import qualified Conf
main :: IO ()
@@ -35,7 +36,9 @@ main = do
middleware $
staticPolicy (noDots >-> addBase "public")
- get "/" $
+ api conf
+
+ notFound $
( do
signInToken <- param "signInToken" :: ActionM Text
successOrError <- validateSignIn conf signInToken
@@ -46,37 +49,43 @@ main = do
(getIndex conf Nothing)
) `rescue` (\_ -> getIndex conf Nothing)
- post "/signOut" signOut
- -- SignIn
+api :: Conf -> ScottyM ()
+api conf = do
+ -- Sign
+
+ post "/api/signIn" $ do
+ email <- param "email" :: ActionM Text
+ signIn conf email
+
+ post "/api/signOut" signOut
+
+ -- Users
- post "/signIn" $ do
- email <- param "email" :: ActionM Text
- signIn conf email
+ get "/api/users" getUsers
+ get "/api/whoAmI" whoAmI
- -- Users
+ -- Incomes
- get "/users" getUsers
- get "/whoAmI" whoAmI
- get "/incomes" getIncomes
- post "/income" $ do
- amount <- param "amount" :: ActionM Int
- setIncome amount
+ get "/api/incomes" getIncomes
+ post "/api/income" $ do
+ amount <- param "amount" :: ActionM Int
+ setIncome amount
- -- Payments
+ -- Payments
- get "/payments" getPayments
+ get "/api/payments" getPayments
- get "/monthlyPayments" getMonthlyPayments
+ get "/api/monthlyPayments" getMonthlyPayments
- 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/add" $ do
+ name <- param "name" :: ActionM Text
+ cost <- param "cost" :: ActionM Text
+ frequency <- param "frequency" :: ActionM Frequency
+ createPayment name cost frequency
- post "/payment/delete" $ do
- paymentId <- param "id" :: ActionM Text
- deletePayment paymentId
+ post "/api/payment/delete" $ do
+ paymentId <- param "id" :: ActionM Text
+ deletePayment paymentId
- get "/payments/count" getPaymentsCount
+ get "/api/payments/count" getPaymentsCount