小编use*_*761的帖子

Nest 无法解析 AuthService (?) 的依赖项。请确保索引 [0] 处的参数在 AuthModule 上下文中可用

Nest 无法解析 AuthService (?) 的依赖项。请确保索引 [0] 处的参数在 AuthModule 上下文中可用。+134ms 错误:Nest 无法解析 AuthService (?) 的依赖关系。请确保索引 [0] 处的参数在 AuthModule 上下文中可用。

我从https://docs.nestjs.com/techniques/authentication复制了代码,然后报了这个错误:

import { Injectable, Inject } from '@nestjs/common';
import { UsersService } from '../users/users.service';
@Injectable()
export class AuthService {
  //constructor(private readonly usersService: UsersService) {}
  constructor(@Inject('UsersService') private UsersService: UsersService) {}
  async validateUser(token: string): Promise<any> {
    // Validate if token passed along with HTTP request
    // is associated with any registered account in the database
    return await this.UsersService.findOneByToken(token);
  }
}
Run Code Online (Sandbox Code Playgroud)
import { …
Run Code Online (Sandbox Code Playgroud)

nestjs

3
推荐指数
1
解决办法
5424
查看次数

如何使用NestJS Redis微服务?

我正在学习nestjs微服务,

我可以使用什么命令?

const pattern = { cmd: 'get' };
this.client.send<any>(pattern, data)
Run Code Online (Sandbox Code Playgroud)

我如何从redis接收数据?

constructor(private readonly appService: AppService) {}
      @Client({
        transport: Transport.REDIS,
        options: {
          url: 'redis://127.0.0.1:6379',
        },
      })
      client: ClientProxy;

      @Get()
      getHello(): any {
        const pattern = { cmd: 'get foo' };  //Please write sample code here in document
        const data = '';
        return this.client.send<any>(pattern, data);
      }

Run Code Online (Sandbox Code Playgroud)

redis node.js typescript microservices nestjs

1
推荐指数
1
解决办法
2080
查看次数

标签 统计

nestjs ×2

microservices ×1

node.js ×1

redis ×1

typescript ×1