Questions tagged [nestjs-config]
196 questions
19
votes
6 answers
Request body not showing in Nest.js + Swagger
My controller code is something like this.
@Controller('customer')
export class CustomerController{
constructor(private readonly customerService: CustomerService){}
@Post('lookup')
async someMethod(@Body() body:any){
…

p0tta
- 1,461
- 6
- 28
- 49
9
votes
1 answer
Nestjs Config access to config in bootstrap level
According to this documentation you import your config in AppModule.
I'm trying to access to config in bootstrap level in my main.ts file.
Something like this:
const app = await NestFactory.create(AppModule);
if (config.get('swagger.enabled'))
…

cheziHoyzer
- 4,803
- 12
- 54
- 81
8
votes
4 answers
eslint + jsconfig + nextjs module path aliases (absolue path import - @)
I am trying to import the files using custom aliases following the nextjs documentation.
My current approach is
from
import Header from '../../../components/Header';
to
import Header from '@components/Header';
I am getting the expected result. But…

gayathrithedev
- 327
- 2
- 10
7
votes
1 answer
@graphql-eslint/eslint-plugin "parserOptions.schema" error
We are developing micro-services in NestJS-typescript.
Each of them exposes a GraphQL schema. In order to expose a single graph, we are using a federation service, also in NestJS.
I was trying to integrate with '@graphql-eslint/eslint-plugin'.
The…

Roy Leibovitz
- 579
- 5
- 16
7
votes
2 answers
Dynamic kafka topic name in nestjs microservice
In Nestjs I am using kafka as message broker and set topic name in like this:
@MessagePattern('topic-name')
async getNewRequest(@Payload() message: any): Promise {
// my code goes here
}
Is there any way to read kafka topic name from config…

Ali Behnamfard
- 101
- 8
7
votes
0 answers
NestJS ConfigService returns undefined values during async TypeORM configuration on app startup
I'm trying to setup configuration for my NestJS app by following some of the following documentation:
Config: https://docs.nestjs.com/techniques/configuration
TypeORM: https://docs.nestjs.com/techniques/database#async-configuration
I've added a .env…

Scott McCartney
- 153
- 1
- 8
7
votes
3 answers
How can I user configService in super()?
I have a question about setting environmental variables.
In official document, it says using ConfigModule in this case, but my case is a exception case.
Because I would like to use it in super() in constructor.
My code is the below.
Is there any…

shun
- 71
- 1
- 2
7
votes
1 answer
NestJS Config partial registration with validation
In the NestJS documentation there is a section about partial registration.
It says it allows to load feature-specific configuration files in different directories:
import databaseConfig from './config/database.config';
@Module({
imports:…

warreee
- 437
- 4
- 12
7
votes
1 answer
How to use ConfigService in Nestjs DatabaseModule
I have created a DatabaseModule using the nestjs typeorm
import { createConnection } from 'typeorm';
import { ConfigService } from '@nestjs/config';
export const databaseConnection = [
{
provide: 'DATABASE_CONNECTION',
…

Tony Roczz
- 2,366
- 6
- 32
- 59
6
votes
4 answers
How to get Nestjs configService instance in main.ts before instantiating app
My app instance depends on configuration : serviceName in that case
const serviceName = 'authentication-service'
const servicePrefix = `api/${serviceName}`;
const swaggerPrefix = 'swagger';
...
const app = await…

jarjar
- 359
- 4
- 10
6
votes
2 answers
Nest.js can't resolve dependencies
I am trying to use ConfigService in my users.module.ts but I am getting an
Error: Nest can't resolve dependencies of the UsersService (UserRepository, HttpService, ?). Please make sure that the argument ConfigService at index [2] is available in…

Istiyak Tailor
- 1,570
- 3
- 14
- 29
5
votes
1 answer
NestJs - ConfigModule.forRoot isGlobal not working
I am trying to load the "process.env.AUTH_SECRET" in AuthModule, but it is giving me the undefined error "Error: secretOrPrivateKey must have a value".
I did setup the "isGlobal: true" in AppModule and it was able to read "process.env.MONGO_URL"…

Sean
- 508
- 6
- 20
5
votes
1 answer
NestJS: Copying Assets not working on Linux
I'm working on a NestJS project and copying my assets works fine on my Mac. However, once I dockerize it it won't work.
nest-cli.json
{
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"assets": [
…

Matt Brandt
- 581
- 1
- 4
- 20
4
votes
2 answers
Nest can't resolve dependencies of the TypeOrmCoreModule
src/contact/contact.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ContactController } from './contact.controller';
import { Contact } from './contact.entity';
import { ContactRepository…

Kishan Donga
- 2,851
- 2
- 23
- 35
4
votes
3 answers
TypeORM / NestJS - @BeforeUpdate hook not working
I'm having problems using TypeOrm hook "BeforeUpdate"
I'm trying to update the user entity password, by passing a simple string and calling the save method to trigger the beforeUpdate hook and then hash the password, but this hook is not working…

Dacxj0
- 141
- 3
- 9