title: How to get user's information in Nest.js?
body: <p>I am using Angular+Nest to develop a website. I have created a service(Angular) so that client can get user's information from server when project start up(the same as fresh). Some actions don't need to login, so the login is optional.</p>
  
  <p>What I want is if user has logined, then client should send a request to get user's information.</p>
  
  <p>Server code as below:</p>
  
  <pre><code>export const RequestUser = createParamDecorator((data, req): RequestUserDTO =&gt; {
      return req.user;
  });
  
  @Controller('auth')
  export class AuthController {
    @Get('getUserInfoByToken')
    async getUserInfoByToken(@RequestUser() user: User): Promise&lt;any&gt; {
      if (user) {
        return {
          nickname: user.nickname,
          level: user.level
        };
      }
    }
  }
  </code></pre>
  
  <p>Howerver, I find there's nothing be return if I don't add <code>@UseGuards(AuthGuard())</code> as decorator. But if I add it, when project start, this request return <code>401</code> as status code. Then the web will turn to login page.</p>
  
  <p>What should I do to avoid this situation? Not every action need login.</p>