Add routes for media outlets, articles, and prediction markets
Adds API endpoints for fetching articles by media outlet slug, prediction markets by article slug, and auction data for media outlets. Includes functionality to place bids on media outlet auctions. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 069d4324-6c40-4355-955e-c714a50de1ea Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/069d4324-6c40-4355-955e-c714a50de1ea/jvFIdY3
This commit is contained in:
@ -205,6 +205,30 @@ export class DatabaseStorage implements IStorage {
|
||||
}
|
||||
|
||||
async placeBid(bid: InsertBid): Promise<Bid> {
|
||||
// First, get the auction to validate
|
||||
const auction = await this.getAuctionById(bid.auctionId);
|
||||
if (!auction) {
|
||||
throw new Error("Auction not found");
|
||||
}
|
||||
|
||||
// Validate auction status
|
||||
if (!auction.isActive) {
|
||||
throw new Error("Auction is not active");
|
||||
}
|
||||
|
||||
// Validate auction end date
|
||||
if (new Date() > auction.endDate) {
|
||||
throw new Error("Auction has ended");
|
||||
}
|
||||
|
||||
// Validate bid amount
|
||||
const currentBidAmount = parseFloat(auction.currentBid || "0");
|
||||
const bidAmount = parseFloat(bid.amount.toString());
|
||||
|
||||
if (bidAmount <= currentBidAmount) {
|
||||
throw new Error(`Bid amount must be higher than current bid of ${currentBidAmount}`);
|
||||
}
|
||||
|
||||
const [newBid] = await db.insert(bids).values(bid).returning();
|
||||
|
||||
// Update auction with highest bid
|
||||
|
||||
Reference in New Issue
Block a user