From 4ce9751c9e645916fdde71874c2cdadd252f32a0 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Mon, 6 Jul 2015 00:16:45 +0200 Subject: Setting up Scotty, Persistent, Clay, Blaze, Esqueleto, Elm --- src/server/Main.hs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/server/Main.hs (limited to 'src/server/Main.hs') 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 -- cgit v1.2.3