Vizzuality/landgriffon

View on GitHub
api/src/decorators/get-user.decorator.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { User } from 'modules/users/user.entity';

export const GetUser: any = createParamDecorator(
  (_data: unknown, context: ExecutionContext): User => {
    const request: any = context.switchToHttp().getRequest();
    return request.user;
  },
);