restructuring
This commit is contained in:
parent
3a3fde8e3a
commit
3575cd265d
2 changed files with 29 additions and 19 deletions
|
@ -8,27 +8,16 @@ module Main where
|
||||||
import Servant
|
import Servant
|
||||||
import Servant.Server.Experimental.Auth
|
import Servant.Server.Experimental.Auth
|
||||||
|
|
||||||
import Data.Time.Clock
|
|
||||||
|
|
||||||
import Data.ByteString.Random
|
|
||||||
import Data.ByteString.Base16 (decode)
|
import Data.ByteString.Base16 (decode)
|
||||||
|
|
||||||
import Data.Set (empty)
|
import Data.Set (empty)
|
||||||
|
|
||||||
import Data.Maybe (isJust)
|
|
||||||
|
|
||||||
import Database.PostgreSQL.Simple
|
import Database.PostgreSQL.Simple
|
||||||
|
|
||||||
import Network.Wai
|
import Network.Wai
|
||||||
import Network.Wai.Logger
|
import Network.Wai.Logger
|
||||||
import Network.Wai.Handler.Warp
|
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.Monad.Reader
|
||||||
|
|
||||||
import Control.Concurrent.STM.TVar
|
import Control.Concurrent.STM.TVar
|
||||||
|
@ -46,13 +35,13 @@ main = do
|
||||||
conn <- connectPostgreSQL
|
conn <- connectPostgreSQL
|
||||||
"host='localhost' port=5432 dbname='mateamt' user='mateamt' password='mateamt'"
|
"host='localhost' port=5432 dbname='mateamt' user='mateamt' password='mateamt'"
|
||||||
store <- newTVarIO empty
|
store <- newTVarIO empty
|
||||||
execute_ conn initUser
|
void $ execute_ conn initUser
|
||||||
execute_ conn initProduct
|
void $ execute_ conn initProduct
|
||||||
execute_ conn initToken
|
void $ execute_ conn initToken
|
||||||
execute_ conn initAmount
|
void $ execute_ conn initAmount
|
||||||
execute_ conn initJournal
|
void $ execute_ conn initJournal
|
||||||
withStdoutLogger $ \log -> do
|
withStdoutLogger $ \ilog -> do
|
||||||
let settings = setPort 3000 $ setLogger log defaultSettings
|
let settings = setPort 3000 $ setLogger ilog defaultSettings
|
||||||
initState = ReadState
|
initState = ReadState
|
||||||
{ rsConnection = conn
|
{ rsConnection = conn
|
||||||
, rsTicketStore = store
|
, rsTicketStore = store
|
|
@ -22,7 +22,27 @@ flag develop
|
||||||
|
|
||||||
executable mateamt
|
executable mateamt
|
||||||
main-is: Main.hs
|
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
|
||||||
, Control.Buy
|
, Control.Buy
|
||||||
, Control.Journal
|
, Control.Journal
|
||||||
|
@ -66,5 +86,6 @@ executable mateamt
|
||||||
, mtl
|
, mtl
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
ghc-options: -Wall
|
||||||
if flag(develop)
|
if flag(develop)
|
||||||
cpp-options: -DDEVELOP
|
cpp-options: -DDEVELOP
|
||||||
|
|
Loading…
Reference in a new issue