feat: add sessions stats endpoint

This commit is contained in:
Carlos Valente
2024-10-20 22:19:33 +02:00
committed by Carlos Valente
parent 71c468d069
commit 82810f1cb1
8 changed files with 71 additions and 3 deletions
@@ -19,10 +19,13 @@ import { willCauseRegeneration } from '../services/rundown-service/rundownCacheU
import { handleLegacyMessageConversion } from './integration.legacy.js';
const throttledUpdateEvent = throttle(updateEvent, 20);
let lastRequest: Date | null = null;
export function dispatchFromAdapter(type: string, payload: unknown, _source?: 'osc' | 'ws' | 'http') {
const action = type.toLowerCase();
const handler = actionHandlers[action];
lastRequest = new Date();
if (handler) {
return handler(payload);
} else {
@@ -30,6 +33,10 @@ export function dispatchFromAdapter(type: string, payload: unknown, _source?: 'o
}
}
export function getLastRequest() {
return lastRequest;
}
type ActionHandler = (payload: unknown) => { payload: unknown };
const actionHandlers: Record<string, ActionHandler> = {