import { createParamDecorator, ExecutionContext } from "@nestjs/common"; import { DEMO_USER_ID } from "./demo-user.js"; /** * Injects the DB userId from the request (set by ClerkAuthGuard). * Falls back to "demo" user id in local dev when no auth is present. */ export const CurrentUser = createParamDecorator( (_data: unknown, ctx: ExecutionContext): string => { const request = ctx.switchToHttp().getRequest<{ userId?: string }>(); return request.userId ?? DEMO_USER_ID; } );