aboutsummaryrefslogtreecommitdiff
path: root/src/server/Main.hs
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-07-06 00:16:45 +0200
committerJoris Guyonvarch2015-07-06 00:16:45 +0200
commit4ce9751c9e645916fdde71874c2cdadd252f32a0 (patch)
tree1014c58787231cbdc3ae2799f32127b40ab393ab /src/server/Main.hs
downloadbudget-4ce9751c9e645916fdde71874c2cdadd252f32a0.tar.gz
budget-4ce9751c9e645916fdde71874c2cdadd252f32a0.tar.bz2
budget-4ce9751c9e645916fdde71874c2cdadd252f32a0.zip
Setting up Scotty, Persistent, Clay, Blaze, Esqueleto, Elm
Diffstat (limited to 'src/server/Main.hs')
-rw-r--r--src/server/Main.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/server/Main.hs b/src/server/Main.hs
new file mode 100644
index 0000000..981c865
--- /dev/null
+++ b/src/server/Main.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+import Web.Scotty
+
+import Network.Wai.Middleware.Static
+
+import Data.Text (Text)
+
+import Application
+
+import Model.Database (runMigrations)
+
+main :: IO ()
+main = do
+ runMigrations
+ scotty 3000 $ do
+ middleware $ staticPolicy (noDots >-> addBase "public")
+ get "/" getIndexAction
+ get "/users" getUsersAction
+ get "/payments" getPaymentsAction
+ post "/user/add" $ do
+ email <- param "email" :: ActionM Text
+ name <- param "name" :: ActionM Text
+ addUserAction email name
+ post "/user/delete" $ do
+ email <- param "email" :: ActionM Text
+ deleteUserAction email
+ post "/payment/add" $ do
+ email <- param "email" :: ActionM Text
+ name <- param "name" :: ActionM Text
+ cost <- param "cost" :: ActionM Int
+ insertPaymentAction email name cost