Add auction creation and bid handlers
[?]
May 4, 2016, 4:19 AM
ASF3UPJLCX7KIUCNJD5KAXSPDXCUEJHLL4HBRTRUBPCW73IXOCWQCDependencies
- [2]
Z3MK2PJ5Add GET handler for retrieving auction data. - [3]
NLZ3JXLOFix formatting with stylish-haskell. - [4]
O5FVTOM6Undo JSON silliness, enable a couple more routes. - [5]
HALRDT2FAdded initial auction create route. - [6]
RPAJLHMTChange to use UUIDs instead of ints for primary keys. - [7]
GCVQD44VCreate amends endpoint, switch to UUID primary keys - [8]
MB5SHULBAdd route for accepting an invitation with an existing account - [9]
2XQD6KKKAdd invitation logic and clean up DBProg error handling. - [10]
5OI44E4EAdd authentication to auction search. - [11]
IZEVQF62Work in progress replacing sqlite with postgres. - [12]
QMRKFEPGRefactor QDB to use a free monad algebra instead. - [13]
MGOF7IUFUpdate TASKS list to reflect completed projects. - [*]
64C6AWH6Rename Ananke -> Quixotic, project reboot. - [*]
WZUHEZSBStart of migration back toward snap. - [*]
W35DDBFYFactor common JSON conversions up into client lib module. - [*]
7HPY3QPFFix linting errors. (yay hlint!) - [*]
Z7KS5XHHVery WIP. Wow. - [*]
ADMKQQGCInitial empty Snap project.
Change contents
- edit in aftok.cabal at line 117
, hourglass - edit in lib/Aftok/Database.hs at line 114
- edit in lib/Aftok/Database.hs at line 176[3.1024]
createBid :: AuctionId -> UserId -> Bid -> DBProg (BidId)createBid aid uid bid = domaybeAuc <- findAuction aid uidlet createOp = CreateBid aid bidfc $ maybe (raiseSubjectNotFound createOp) (const createOp) maybeAuc - edit in lib/Aftok/Json.hs at line 90
projectIdJSON :: ProjectId -> ValueprojectIdJSON pid = v1 $object [ "projectId" .= tshow (pid ^. _ProjectId) ] - edit in lib/Aftok/Json.hs at line 102
auctionIdJSON :: AuctionId -> ValueauctionIdJSON pid = v1 $object [ "auctionId" .= tshow (pid ^. _AuctionId) ] - edit in lib/Aftok/Json.hs at line 112
bidIdJSON :: BidId -> ValuebidIdJSON pid = v1 $object [ "bidId" .= tshow (pid ^. _BidId) ] - edit in lib/Aftok/Json.hs at line 117
- edit in server/Aftok/Snaplet/Auctions.hs at line 6
, auctionBidHandler - edit in server/Aftok/Snaplet/Auctions.hs at line 13
import Data.Hourglass.Types (Seconds(..)) - replacement in server/Aftok/Snaplet/Auctions.hs at line 16
import Aftok.Auction (AuctionId, Auction(..))import Aftok.Database (createAuction, findAuction)import Aftok (UserId)import Aftok.Auction (AuctionId, Auction(..), BidId, Bid(..))import Aftok.Database (createAuction, findAuction, createBid) - edit in server/Aftok/Snaplet/Auctions.hs at line 34
_ -> mzerobidCreateParser :: UserId -> C.UTCTime-> Value -> Parser BidbidCreateParser uid t = unv1 "bids" $ \v ->case v of(Object o) -> Bid uid <$> (Seconds <$> o .: "bidSeconds")<*> (Satoshi <$> o .: "bidAmount")<*> pure t - replacement in server/Aftok/Snaplet/Auctions.hs at line 57
maybeAuc <- snapEval $ findAuction aid uidmaybeAuc <- snapEval $ findAuction aid uid -- this will verify auction access - edit in server/Aftok/Snaplet/Auctions.hs at line 59[2.1231]
auctionBidHandler :: Handler App App BidIdauctionBidHandler = douid <- requireUserIdaid <- requireAuctionIdtimestamp <- liftIO C.getCurrentTimerequestBody <- readRequestJSON 4096bid <- either (snapError 400 . tshow) pure $ parseEither (bidCreateParser uid timestamp) requestBodysnapEval $ createBid aid uid bid - replacement in server/Main.hs at line 43
projectCreateRoute = void $ method POST projectCreateHandlerprojectCreateRoute = serveJSON projectIdJSON $ method POST projectCreateHandler - replacement in server/Main.hs at line 47
logEventRoute f = serveJSON eventIdJSON . method POST $ logWorkHandler flogEventRoute f = serveJSON eventIdJSON $ method POST (logWorkHandler f) - replacement in server/Main.hs at line 53
auctionCreateRoute = void $ method POST auctionCreateHandlerauctionCreateRoute = serveJSON auctionIdJSON $ method POST auctionCreateHandler - edit in server/Main.hs at line 55
auctionBidRoute = serveJSON bidIdJSON $ method POST auctionBidHandler - edit in server/Main.hs at line 76
, ("auctions/:auctionId/bid", auctionBidRoute)