diff options
author | Joris | 2021-01-03 13:40:40 +0100 |
---|---|---|
committer | Joris | 2021-01-03 13:54:20 +0100 |
commit | 11052951b74b9ad4b6a9412ae490086235f9154b (patch) | |
tree | 64526ac926c1bf470ea113f6cac8a33158684e8d /server/src/Main.hs | |
parent | 371449b0e312a03162b78797b83dee9d81706669 (diff) | |
download | budget-11052951b74b9ad4b6a9412ae490086235f9154b.tar.gz budget-11052951b74b9ad4b6a9412ae490086235f9154b.tar.bz2 budget-11052951b74b9ad4b6a9412ae490086235f9154b.zip |
Rewrite in Rust
Diffstat (limited to 'server/src/Main.hs')
-rw-r--r-- | server/src/Main.hs | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/server/src/Main.hs b/server/src/Main.hs deleted file mode 100644 index 659a0fa..0000000 --- a/server/src/Main.hs +++ /dev/null @@ -1,106 +0,0 @@ -module Main - ( main - ) where - -import qualified Network.HTTP.Types.Status as Status -import Network.Wai.Middleware.Gzip (GzipFiles (GzipCompress)) -import qualified Network.Wai.Middleware.Gzip as W -import Network.Wai.Middleware.Static -import qualified Web.Scotty as S - -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.Statistics as Statistics -import qualified Controller.User as User -import qualified Design.Global as Design -import Job.Daemon (runDaemons) - -main :: IO () -main = do - conf <- Conf.get "application.conf" - putStrLn . show $ conf - _ <- runDaemons conf - S.scotty (Conf.port conf) $ do - - S.middleware $ - W.gzip $ W.def { W.gzipFiles = GzipCompress } - - S.middleware . staticPolicy $ - noDots >-> addBase "public" - - S.get "/css/main.css" $ do - S.setHeader "Content-Type" "text/css" - S.text Design.globalDesign - - S.post "/api/signIn" $ - S.jsonData >>= Index.signIn conf - - S.post "/api/signOut" $ - Index.signOut conf - - S.get "/api/users"$ - User.list - - S.get "/api/payments" $ do - frequency <- S.param "frequency" - page <- S.param "page" - perPage <- S.param "perPage" - search <- S.param "search" - Payment.list (read frequency) page perPage search - - S.get "/api/payment/category" $ do - name <- S.param "name" - Payment.searchCategory name - - S.post "/api/payment" $ - S.jsonData >>= Payment.create - - S.put "/api/payment" $ - S.jsonData >>= Payment.edit - - S.delete "/api/payment/:id" $ do - paymentId <- S.param "id" - Payment.delete paymentId - - S.get "/api/incomes" $ do - page <- S.param "page" - perPage <- S.param "perPage" - Income.list page perPage - - S.post "/api/income" $ - S.jsonData >>= Income.create - - S.put "/api/income" $ - S.jsonData >>= Income.edit - - S.delete "/api/income/:id" $ do - incomeId <- S.param "id" - Income.delete incomeId - - S.get "/api/allCategories" $ do - Category.listAll - - S.get "/api/categories" $ do - page <- S.param "page" - perPage <- S.param "perPage" - Category.list page perPage - - S.post "/api/category" $ - S.jsonData >>= Category.create - - S.put "/api/category" $ - S.jsonData >>= Category.edit - - S.delete "/api/category/:id" $ do - categoryId <- S.param "id" - Category.delete categoryId - - S.get "/api/statistics" $ do - Statistics.paymentsAndIncomes - - S.notFound $ do - S.status Status.ok200 - Index.get conf |