| // 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 | |
| } | |