restructuring

This commit is contained in:
nek0 2019-09-07 02:48:05 +02:00
parent 3a3fde8e3a
commit 3575cd265d
2 changed files with 29 additions and 19 deletions

View file

@ -8,27 +8,16 @@ module Main where
import Servant
import Servant.Server.Experimental.Auth
import Data.Time.Clock
import Data.ByteString.Random
import Data.ByteString.Base16 (decode)
import Data.Set (empty)
import Data.Maybe (isJust)
import Database.PostgreSQL.Simple
import Network.Wai
import Network.Wai.Logger
import Network.Wai.Handler.Warp
import Opaleye hiding (max)
import Control.Monad.IO.Class (liftIO)
import Control.Monad (void)
import Control.Monad.Reader
import Control.Concurrent.STM.TVar
@ -46,13 +35,13 @@ main = do
conn <- connectPostgreSQL
"host='localhost' port=5432 dbname='mateamt' user='mateamt' password='mateamt'"
store <- newTVarIO empty
execute_ conn initUser
execute_ conn initProduct
execute_ conn initToken
execute_ conn initAmount
execute_ conn initJournal
withStdoutLogger $ \log -> do
let settings = setPort 3000 $ setLogger log defaultSettings
void $ execute_ conn initUser
void $ execute_ conn initProduct
void $ execute_ conn initToken
void $ execute_ conn initAmount
void $ execute_ conn initJournal
withStdoutLogger $ \ilog -> do
let settings = setPort 3000 $ setLogger ilog defaultSettings
initState = ReadState
{ rsConnection = conn
, rsTicketStore = store

View file

@ -22,7 +22,27 @@ flag develop
executable mateamt
main-is: Main.hs
other-modules: API
-- other-extensions:
build-depends: base ^>=4.12.0.0
, mateamt
, base16-bytestring
, containers
, mtl
, opaleye
, postgresql-simple
, stm
, servant
, servant-server
, time
, warp
, wai
, wai-logger
hs-source-dirs: app
ghc-options: -Wall
default-language: Haskell2010
library
exposed-modules: API
, Control
, Control.Buy
, Control.Journal
@ -66,5 +86,6 @@ executable mateamt
, mtl
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall
if flag(develop)
cpp-options: -DDEVELOP