Here is the structure of my app.module.ts file:
import { Module, HttpModule } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { join } from 'path';
import { LaunchService } from './launch/launch.service';
import { LaunchResolver } from './launch/launch.resolver';
import { LaunchModule } from './launch/launch.module';
import { LogService } from '@fmr-pr103625/nest-scaffold';
@Module({
imports: [
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
typePaths: ['./**/*.graphql'],
definitions: { path: join(process.cwd(), 'src/graphql.ts') },
}),
HttpModule,
LaunchModule,
],
controllers: [AppController],
providers: [AppService, LaunchService, LaunchResolver, LogService],
})
export class AppModule {}
The content of my app.service.ts file is as follows:
import { Injectable } from '@nestjs/common';
import { Logger, LogService } from '@fmr-pr103625/nest-scaffold';
@Injectable()
export class AppService {
@Logger()
private logger: LogService;
getHello(): string {
this.logger.error('Hello');
return 'Hello World!';
}
}
I am facing an error while trying to use the built-in logservice from another repository.
Nest can't resolve dependencies of the LogService (?, LogFormatProvider). Please make sure that the argument String at index [0] is available in the AppModule context.
Potential solutions:
- If String is a provider, ensure it is part of the current AppModule.
- If String is exported from a separate @Module, ensure that module is imported within AppModule.
@Module({
imports: [ /* import the Module containing String */ ]
})
---------------------------**********************---------------------------------
Let me know what I might have missed and how I can resolve this issue. I am simply testing the LogService functionality.
--------------------------**********************-----------------------------------
The code for the Log Service is shown below:
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogService = void 0;
// The implementation details are provided here...
exports.LogService = LogService;
---------------------------*************************-------------------------------