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.hs64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/server/Main.hs b/src/server/Main.hs
deleted file mode 100644
index 17c2594..0000000
--- a/src/server/Main.hs
+++ /dev/null
@@ -1,64 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-import Network.Wai.Middleware.Static
-import qualified Data.Text.Lazy as LT
-import Web.Scotty
-
-import Job.Daemon (runDaemons)
-import qualified Conf
-import qualified Controller.Category as Category
-import qualified Controller.Income as Income
-import qualified Controller.Index as Index
-import qualified Controller.Payment as Payment
-import qualified Controller.SignIn as SignIn
-
-main :: IO ()
-main = do
- conf <- Conf.get "application.conf"
- _ <- runDaemons conf
- scotty (Conf.port conf) $ do
- middleware . staticPolicy $ noDots >-> addBase "public"
-
- get "/" $ do
- signInToken <- mbParam "signInToken"
- Index.get conf signInToken
-
- post "/signIn" $ do
- email <- param "email"
- SignIn.signIn conf email
-
- post "/signOut" $
- Index.signOut conf
-
- post "/payment" $
- jsonData >>= Payment.create
-
- put "/payment" $
- jsonData >>= Payment.editOwn
-
- delete "/payment" $ do
- paymentId <- param "id"
- Payment.deleteOwn paymentId
-
- post "/income" $
- jsonData >>= Income.create
-
- put "/income" $
- jsonData >>= Income.editOwn
-
- delete "/income" $ do
- incomeId <- param "id"
- Income.deleteOwn incomeId
-
- post "/category" $
- jsonData >>= Category.create
-
- put "/category" $
- jsonData >>= Category.edit
-
- delete "/category" $ do
- categoryId <- param "id"
- Category.delete categoryId
-
-mbParam :: Parsable a => LT.Text -> ActionM (Maybe a)
-mbParam key = (Just <$> param key) `rescue` (const . return $ Nothing)