flowstate / src /lib /event-store.ts
muthuk1's picture
feat: full Torque integration — live events, toast, bulk rescue, auto-scan
c6b6c96
raw
history blame contribute delete
621 Bytes
// In-memory store for live Torque events fired this session.
// Module-level singleton — persists across API route calls in the same Node.js process.
export interface LiveEvent {
ingestionId: string
wallet: string
eventName: string
risk?: string
score?: number
firedAt: string
source: 'scan' | 'manual' | 'agent'
}
const store: LiveEvent[] = []
export function pushEvent(e: LiveEvent) {
store.unshift(e)
if (store.length > 100) store.splice(100)
}
export function getEvents(limit = 20): LiveEvent[] {
return store.slice(0, limit)
}
export function getCount(): number {
return store.length
}