Add functionality to upload and display articles with associated images
Update article page to handle image uploads and display articles from text files. Refactor currency and date formatting, and add a method to fetch prediction markets by ID. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 0fb68265-c270-4198-9584-3d9be9bddb41 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/0fb68265-c270-4198-9584-3d9be9bddb41/rOJiPGe
This commit is contained in:
@ -259,7 +259,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
res.status(201).json(bet);
|
||||
} catch (error) {
|
||||
console.error("Error placing prediction bet:", error);
|
||||
if (error.message === "Prediction market not found") {
|
||||
if (error instanceof Error && error.message === "Prediction market not found") {
|
||||
return res.status(404).json({ message: "Prediction market not found" });
|
||||
}
|
||||
res.status(500).json({ message: "Failed to place bet" });
|
||||
|
||||
@ -51,6 +51,7 @@ export interface IStorage {
|
||||
|
||||
// Prediction market operations
|
||||
getPredictionMarkets(articleId?: string): Promise<PredictionMarket[]>;
|
||||
getPredictionMarketById(id: string): Promise<PredictionMarket | undefined>;
|
||||
createPredictionMarket(market: InsertPredictionMarket): Promise<PredictionMarket>;
|
||||
|
||||
// Auction operations
|
||||
@ -188,6 +189,11 @@ export class DatabaseStorage implements IStorage {
|
||||
return await db.select().from(predictionMarkets).where(eq(predictionMarkets.isActive, true)).orderBy(desc(predictionMarkets.createdAt));
|
||||
}
|
||||
|
||||
async getPredictionMarketById(id: string): Promise<PredictionMarket | undefined> {
|
||||
const [market] = await db.select().from(predictionMarkets).where(eq(predictionMarkets.id, id));
|
||||
return market;
|
||||
}
|
||||
|
||||
async createPredictionMarket(market: InsertPredictionMarket): Promise<PredictionMarket> {
|
||||
const [newMarket] = await db.insert(predictionMarkets).values(market).returning();
|
||||
return newMarket;
|
||||
@ -323,7 +329,7 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
const [newBet] = await db.insert(predictionBets).values({
|
||||
...bet,
|
||||
price: price.toString()
|
||||
price: price?.toString() || "0.5"
|
||||
}).returning();
|
||||
|
||||
// Update market volume and bet count
|
||||
|
||||
Reference in New Issue
Block a user