import { createParamDecorator, ExecutionContext } from "@nestjs/common";

// TODO: integrate @edr/auth — this decorator currently returns whatever was
// attached to request.user by the (not-yet-wired) auth middleware. Once the
// auth package is integrated, replace this with the real user type.
export const CurrentUser = createParamDecorator(
  (_data: unknown, ctx: ExecutionContext) => {
    const request = ctx.switchToHttp().getRequest();
    return request.user ?? null;
  },
);
