WZUHEZSBRKHQMNWDKVG4X6DDIQEAXTGI6IGAJ5ERPRQ3W2KUMX4QC
Z3M53KTLZMPOISMHE25SZJSWX5TA37IV33IRE7KNRAD3PKEAEJXQC
64C6AWH66FDKU6UE6Z6JPX2J2GBM2JOPTH2GL6LHKAIUBGNGDZ5AC
64VI73NPSFNWTL6UXM6YHRFLNJZ3NUJ2R3CL53MO2HSZWFGBIRTQC
EQXRXRZDYCM7BDAVBOXQYPG6C7IJT3OFGNIXCDAHJJBRKAXNGL7AC
RSEB2NFGUBTFESE5BJKDUVQL5Y5ZVGY5O4CJX2LNP63MS3NRHHZQC
ADMKQQGCGVSHHIMVQ4XFRDCG544SBJCYALSKZV45CQQBZ4ACUH2AC
build-depends: quixotic
, base
, aeson
, containers
, either
, mtl
, sqlite
, text
, time
, configurator == 0.2.*
, optparse-applicative >= 0.9.0 && < 0.10
, bytestring >= 0.9.1 && < 0.11
, scotty >= 0.9.0
build-depends:
quixotic
, base >= 4 && < 5
, aeson
, containers
, either
, mtl >= 2 && < 3
, sqlite
, text
, time
, MonadCatchIO-transformers >= 0.2.1 && < 0.4
, configurator == 0.2.*
, optparse-applicative >= 0.9.0 && < 0.10
, bytestring >= 0.9.1 && < 0.11
, snap-core >= 0.9 && < 0.10
, snap-server >= 0.9 && < 0.10
module Api.Worklog (resource) where
import Control.Applicative ((<$>))
import Control.Concurrent.STM (atomically, modifyTVar, readTVar)
import Control.Monad.Error (throwError)
import Control.Monad.Reader (ReaderT, asks)
import Control.Monad.Trans (liftIO)
import Data.Set (Set)
import qualified Data.Foldable as F
import qualified Data.Set as Set
import qualified Data.Text as T
import Rest (Handler, ListHandler, Range (count, offset), Resource, Void, domainReason, mkInputHandler, mkListing, mkResourceReader, named, singleRead,
withListing, xmlJsonE, xmlJsonI, xmlJsonO)
import qualified Rest.Resource as R
import ApiTypes (BlogApi, ServerData (..))
import Type.User (User)
import Type.UserInfo (UserInfo (..))
import Type.UserSignupError (UserSignupError (..))
import qualified Type.User as User
import qualified Type.UserInfo as UserInfo
resource ::
module Api (api) where
import Rest.API
data QConfig
= QConfig
site :: QConfig -> a -> ADB IO a -> Snap ()
site cfg db adb =
route [ ("logStart/:btcAddr", handleLogRequest db adb StartWork)
, ("logEnd/:btcAddr", handleLogRequest db adb StopWork)
, ("payouts", currentPayouts db adb)
]
data QConfig = QConfig
dbMain :: QConfig -> a -> ADB IO a -> IO ()
dbMain cfg db adb = do
scotty (port cfg) $ do
{--
Log the start time of a work interval.
Log completion of the current work interval.
Record change of a work interval start.
Record change of a work interval end.
Given a trusted token, authorize another token.
--}
post "/logStart/:btcAddr" $ handleLogRequest db adb StartWork
post "/logEnd/:btcAddr" $ handleLogRequest db adb StopWork
get "/payouts" $ currentPayouts db adb
handleLogRequest :: a -> ADB IO a -> (UTCTime -> WorkEvent) -> ActionM ()
handleLogRequest :: a -> ADB IO a -> (UTCTime -> WorkEvent) -> Snap ()