feat: payment routes + ranked queue endpoint + app wiring
Add /api/payments router (connect-wallet, wallet-status, create-invoice, check, submit-cashu, winnings, claim, disconnect-wallet). Add ranked queue endpoints to /api/queue. Mount payments router in app.ts with orphan payment recovery on startup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e046cb13eb
commit
460564a8ee
@@ -2,6 +2,7 @@ import { Hono } from 'hono'
|
||||
import { db, schema } from '../db/index.js'
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { joinQueue, leaveQueue, getQueueSize, getQueueSnapshot } from '../engine/queue.js'
|
||||
import { joinRankedQueue, getRankedQueueStatus } from '../engine/ranked-queue.js'
|
||||
|
||||
export const queueRouter = new Hono()
|
||||
|
||||
@@ -41,3 +42,26 @@ queueRouter.post('/leave/:botId', (c) => {
|
||||
const left = leaveQueue(botId)
|
||||
return c.json({ left })
|
||||
})
|
||||
|
||||
// Get ranked queue status
|
||||
queueRouter.get('/ranked-status', (c) => {
|
||||
return c.json(getRankedQueueStatus())
|
||||
})
|
||||
|
||||
// Join ranked queue — requires confirmed payment
|
||||
queueRouter.post('/join-ranked/:botId', async (c) => {
|
||||
const botId = c.req.param('botId')
|
||||
const { paymentId } = await c.req.json<{ paymentId: string }>()
|
||||
|
||||
if (!paymentId) {
|
||||
return c.json({ error: 'Missing paymentId' }, 400)
|
||||
}
|
||||
|
||||
try {
|
||||
const fightId = await joinRankedQueue(botId, paymentId)
|
||||
return c.json({ fightId, message: 'Ranked match found! Fight starting.' })
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : 'Ranked queue error'
|
||||
return c.json({ error: message }, 500)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user