2026-07-29 05:53:13 -04:00
|
|
|
// AGENT INSTRUCTION: After every write (INSERT/UPDATE/DELETE), you MUST:
|
|
|
|
|
// 1. Insert activity feed entry
|
|
|
|
|
// 2. Call pg.notify('project_e_events', JSON.stringify({ type, action, id, workspace_id }))
|
|
|
|
|
// See AGENTS.md for full rules.
|
|
|
|
|
|
2026-07-16 06:19:58 -04:00
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
2026-07-24 07:08:29 -04:00
|
|
|
import { getAuthUser } from '@/lib/auth';
|
2026-07-16 06:19:58 -04:00
|
|
|
|
|
|
|
|
export async function GET(request: NextRequest) {
|
|
|
|
|
try {
|
2026-07-24 07:08:29 -04:00
|
|
|
const user = await getAuthUser(request);
|
|
|
|
|
if (!user) {
|
2026-07-16 06:19:58 -04:00
|
|
|
return NextResponse.json(
|
|
|
|
|
{ error: { code: 'UNAUTHORIZED', message: 'Not authenticated' } },
|
|
|
|
|
{ status: 401 }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-24 07:08:29 -04:00
|
|
|
return NextResponse.json({ user });
|
2026-07-16 06:19:58 -04:00
|
|
|
} catch {
|
|
|
|
|
return NextResponse.json(
|
|
|
|
|
{ error: { code: 'AUTH_ERROR', message: 'Invalid or expired token' } },
|
|
|
|
|
{ status: 401 }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|