Files
WRNexusJS/examples/basic-app/app/api/me.ts
T
2026-07-12 15:55:18 +05:30

12 lines
481 B
TypeScript

// API route: GET /api/me. Protected by requireAuth — returns 401 when anonymous,
// otherwise the current user hydrated onto ctx by the auth middleware.
import { requireAuth, getUser, type Context } from "@wrnexus/core";
const guard = requireAuth();
export async function GET(ctx: Context): Promise<Response> {
const denied = await guard(ctx, () => new Response(null));
if (denied.status === 401) return denied;
return Response.json({ ok: true, user: getUser(ctx) });
}