I have a micro services architecture which pass through my api-gateway service : authentication and users.
My users and authentication services are both working and logs show everything is OK.
But the log of my ApiGatewayService throws an error :
Error: Nest can't resolve dependencies of the ApiGatewayService (?, AUTHENTICATION_SERVICE). Please make sure that the argument "USER_SERVICE" at index [0] is available in the AppModule context.
api_gateway-1 |
api_gateway-1 | Potential solutions:
api_gateway-1 | - Is AppModule a valid NestJS module?
api_gateway-1 | - If "USER_SERVICE" is a provider, is it part of the current AppModule?
api_gateway-1 | - If "USER_SERVICE" is exported from a separate @Module, is that module imported within AppModule?
api_gateway-1 | @Module({
api_gateway-1 | imports: [ /* the Module containing "USER_SERVICE" */ ]
api_gateway-1 | })
api-gateway.module.ts :
import { Module, Global } from '@nestjs/common';
import { ApiGatewayService } from './api-gateway.service';
import { ApiGatewayController } from './api-gateway.controller';
import { ClientsModule, Transport } from '@nestjs/microservices';
@Global()
@Module({
imports: [
ClientsModule.register([
{
name: "USER_SERVICE",
transport: Transport.TCP,
options: {
host: 'users',
port: 3002,
},
},
{
name: "AUTHENTICATION_SERVICE",
transport: Transport.TCP,
options: {
host: 'authentication',
port: 3001,
},
},
]),
],
controllers: [ApiGatewayController],
providers: [ApiGatewayService],
exports: [ApiGatewayService],
})
export class ApiGatewayModule {}