BidHub Cloud Code Backend
Backend code for HubSpot's open-source silent auction app. For an overview of the auction app project, check out our blog post about it!
The iOS and Android auction apps are backed by Parse, a popular and free backend-as-a-service. Parse handles the database, and also allows you to add server-side logic that occurs when an action is taken (such as a client posting a new bid). This repository contains all of that server-side logic, as well as this helpful README that'll get you set up with Parse.
- Sign up for Parse.
git clonethis repository and edit config/global.json to include your app's name, application ID, and master key (you can find these in Parse by going to Settings > Keys).
- Install the Parse Command Line Tool.
- From the AuctionAppCloudCode directory, run
Initializing the Database
parse deploy command pushed cloud/main.js to Parse. You can see it in Parse by going to Core > Cloud Code. The first two functions contain all of the logic that runs before and after a NewBid is saved, and are run automatically by Parse. The third, InitializeForAuction, is a manual job that will set up your Item and NewBid tables with the correct columns.
Scheduling the job should result in the screen below. Click Run Now to run the job. That's it!
Now, if you go to Data (on the left), you should see the Item and NewBid tables. Item will be populated with a Test Object, and both will have a number of auction-related columns.
The easiest way to add an item is directly from Parse. Go to Core > Data > Item and add either a single item via the +Row button or many items via a CSV import.
That's it! You're all set up, and you can go play with the iOS and Android apps now. You can also grab the Web Panel to keep an eye on the auction. If you're interested in the data models, read on for a short description.
Represents a thing or service for sale.
allBiddersemail addresses of everyone who has bid on this item
closetimeafter this time, bidding is closed
currentPricecurrent highest bid on this item (if qty > 1 and qty == n, highest n bids)
currentWinnersemail address of the current winner of this item (or n winners if qty > 1)
descriptionlong-form description of this item
donornamename of donor
nameshort(ish) name for this item
numberOfBidstotal number of bids for this item
opentimebefore this time, bidding is closed
previousWinnersemail address(es) of who was winning this item before the latest bid. Used by the server-side logic to send pushes only to people who are no longer winning an item.
pricebids start at or above this price
qtyhow many of this item is available. For example, if 3 are available, the highest 3 bidders win.
Represents a single bid on an item.
amttotal dollar amount of bid
itemobjectId of item this bid is for