diff options
Diffstat (limited to 'src/server/Main.hs')
-rw-r--r-- | src/server/Main.hs | 32 |
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 |