rebreak-monorepo/backend/server/api/me/last-seen.post.ts
chahinebrini c89f541069 fix(presence): missing touchLastSeen import in /api/me/last-seen
Endpoint warf 500 jedem Heartbeat-Call (ReferenceError) — Floodete
pm2-Logs. Import war im DB-Layer-File implementiert aber nicht vom
Endpoint importiert.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 06:35:11 +02:00

23 lines
742 B
TypeScript

/**
* POST /api/me/last-seen
*
* Heartbeat endpoint — sets Profile.lastSeenAt = NOW() for the authenticated user.
* No request body required.
*
* Phase 1 fallback: frontend calls this on a ~60s interval while app is foregrounded.
* Phase 2 (TODO): replace with Supabase Edge-Function triggered on presence-leave
* events for sub-second accuracy without client-side polling.
*
* Response: { lastSeenAt: ISOString }
*/
import { requireUser } from "../../utils/auth";
import { touchLastSeen } from "../../db/profile";
export default defineEventHandler(async (event) => {
const user = await requireUser(event);
const now = await touchLastSeen(user.id);
return { success: true, data: { lastSeenAt: now.toISOString() } };
});