Files
memind/health-channel-session-store.mjs
T
john 7bf16500a1 feat(health): wire H5 health page, WeChat channel, and observation API.
Expose /health and /api/health/observations behind MEMIND_HEALTH_ENABLED, redirect ordinary chat health intents without persisting, and run a dedicated WeChat menu flow with confirm-before-write semantics.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 18:04:26 +08:00

29 lines
701 B
JavaScript

const IDLE_TTL_MS = 30 * 60 * 1000;
export function createHealthChannelSessionStore({ ttlMs = IDLE_TTL_MS } = {}) {
const sessions = new Map();
return {
ttlMs,
get(userId) {
const key = String(userId);
const current = sessions.get(key);
if (!current) return null;
if (Date.now() - current.updatedAt > ttlMs) {
sessions.delete(key);
return { expired: true, session: current };
}
return { expired: false, session: current };
},
set(userId, session) {
sessions.set(String(userId), {
...session,
updatedAt: Date.now(),
});
},
clear(userId) {
sessions.delete(String(userId));
},
};
}