Questions tagged [nestjs-config]
196 questions
2
votes
0 answers
how to use csrf protection in nestjs fastify adapter
I am new in nestjs and trying to do nestjs csrf security with fastify adpater. The document doesn't say much how to do.
This is how I am trying to do
import fastifyCsrf from 'fastify-csrf';
and using it inside main.ts file like…

Hkm Sadek
- 2,987
- 9
- 43
- 95
2
votes
2 answers
Nestjs validation pipe not working with Graphql
I am new to nestJS and I have added a ValidationPipe() to main.ts
app.useGlobalPipes(new ValidationPipe())
Now I am using class-validator decorators inside my DTO's but nothing is working right now.
I am using GraphQl but as I have already…

Rahul Agrawal
- 303
- 3
- 12
2
votes
0 answers
Dynamic configuration and persistent storage for config
I have the following two requirements in my NestJS application:
Dynamic configuration - allow users to change configuration values at runtime and allow for observing changes in configuration and take some action based on it.
Database storage -…

Omkar Patil
- 61
- 1
- 2
- 7
2
votes
1 answer
How to set default time zone in Nestjs?
I tried below script but it didn't work.
{
"scripts": {
"start": "TZ='UTC' nest start"
}
}
[System Information]
OS Version : Linux 5.4
NodeJS Version : v12.18.3
NPM Version : 6.14.6
[Nest CLI]
Nest CLI Version : 7.4.1
[Nest…

Pankaj Salunkhe
- 235
- 1
- 5
- 8
2
votes
2 answers
How to set up config in NestJS properly?
I'm using nest-modules/mailer to send an email and I have some trouble during the config setup for MailerModule.
(1) Previously I was using a raw dotenv package to my config in main.ts like:
dotenv.config({
path: 'src/config/config.env',
});
…

Zchary
- 968
- 7
- 14
2
votes
1 answer
Can I get config fro database in appModule with @nestjs/cofnig?
I want to use @nestjs to manage configuration files.
Now I have used the following ways to connect mysql and redis.
// app.module.ts
import { Module } from '@nestjs/common'
import { SequelizeModule } from '@nestjs/sequelize'
import { RedisModule }…

gyh9457
- 23
- 1
- 3
2
votes
1 answer
How to write the response from nestjs exception filters using nestfastify
I have an issue in writing custom http response from nestjs exception filters
I'm using the nest fastify one (not the express)
I'm creating custom exception filters that catch UserNotFoundException as follows:
@Catch(UserNotFoundException)
export…

rizesky
- 424
- 6
- 13
2
votes
0 answers
How to catch NestJS exceptions thrown in `forFeature` or `forRoot`?
I setuped configuration validation as described in documentation of NestJS: https://docs.nestjs.com/techniques/configuration#schema-validation
Validation works as expected, but when my .env file is not valid, I am getting plain error, for…

Baterka
- 3,075
- 5
- 31
- 60
2
votes
3 answers
How to inject NestJS config into TypeORM entity?
Let's have simplified TypeORM entity User:
@Entity()
export class User extends BaseDatabaseEntity {
@Column({
length: 255,
})
public firstName!: string;
@Column({ length: 60 })
@Exclude()
public password: string;
@BeforeUpdate()
…

Baterka
- 3,075
- 5
- 31
- 60
2
votes
1 answer
Mocking HTTP interceptors in Nest JS
I have a core module that provides an authentication interceptor in Nest js.
Here is the core module.
@Module({
imports: [
providers: [{
provide: APP_INTERCEPTOR,
useClass: LoggerInterceptor
}
]
})
export class…

uncle-tee
- 348
- 4
- 10
1
vote
0 answers
Creating service instance using nestJS DI - not for web request
I have two problems using nestJs DI (and unfortunately the documentations are all the same and contains only basic usage information about the topics):
what if I construct an AppModule, and simple I need to create a service just in case (currently…

Zoltan Hernyak
- 989
- 1
- 14
- 35
1
vote
0 answers
TypeORMError: Driver not Connected - NestJs
I am setting up a NestJs application with TypeORM and postgres driver.
I have the required packages needed ("pg": "^8.11.0" and other typeorm packages).
data-source.ts
import 'reflect-metadata';
import { DataSource } from 'typeorm';
export const…

nirvair
- 4,001
- 10
- 51
- 85
1
vote
1 answer
Nestjs with JWT - secretOrPrivateKey must have a value error - when calling a this.jwtService.sign()
I am building a simple Nestjs (v9) api and trying to implement the login functionality. Creating a user in the database worked (postgres, docker image) and the password is hashed. However, when I try to log in (http://localhost:3000/users/login),…

r00k13
- 215
- 3
- 15
1
vote
1 answer
elastic beanstalk get error 502 Bad Gateway when i trying deploy nestjs
25
I am running a nest.js app on Amazon Elastic Beanstalk and my environment was successfully created, but when I go to my environment via the URL Amazon has created, I receive a 502 Bad Gateway nginx/1.6.2 error. I believe Elastic Beanstalk runs…

Anh Dang Vien
- 180
- 8
1
vote
0 answers
How to fix nestjs-typegoose dependency problem in a correct way without --legacy-peer-deps?
I have created a new NestJS project and wanted to install nestjs-typegoose. In the process, I got the following error:
npm i nestjs-typegoose
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While…

r00k13
- 215
- 3
- 15