Questions tagged [nestjs]
Nest (NestJS) is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with and fully supports TypeScript.
8,223
questions
0
votes
0
answers
6
views
Event handler is registered twice nestjs
@Module({
imports: [CqrsModule],
providers: [
userAuthHandlers.UserSignInEventHandler,
],
})
export class EventHandlerModule {
constructor() {}
}
the event handler code
@EventsHandler(...
0
votes
0
answers
8
views
serialize nested objects using class-transformer : Nest js
I am trying to serialize nested objects using a class transformer. I have two dtos like below. When I am trying to serialize using plainToClass the nested object gets removed from the output. only ...
0
votes
0
answers
23
views
TypeORM insert row with one to one relationship
I have three tables user, userCareerProfile, userPersonalProfile with @OneToOne relationship.
User Entity:
@Entity({ name: 'users' })
export class User extends AbstractEntity {
@Column({ unique: ...
0
votes
0
answers
20
views
How to detect the attachment sent?
a pleasure to greet you, I wanted to consult you on a topic.
I am working on sending mail using nodemailer as transport. At this time, we have configured ourselves to be able to send emails to ...
0
votes
0
answers
12
views
{ user_id } is incrementing when im requesting an access token in Instagram Basic Display API using Insomnia and Axios
Im sending "POST" request to https://api.instagram.com/oauth/access_token to obtain an access token in order to fetch instagram user basic info. But I notice when im calling the api above ...
0
votes
1
answer
19
views
How to create a test for the below controller?
do I need to write a test for the below code?
@Post()
update(@Body() updateUserDto: UpdateUserDto, @Request() req) {
return this.userService.update(req.user.user, updateUserDto);
}
0
votes
0
answers
17
views
Module not found in Nest JS after deploying to App engine
I tried to deploy a Nest JS app to App Engine through Google Build Cloud & Manually
Both tries gives same error Modules not found
Error when deploying manually through Shell
Error when dploying ...
1
vote
0
answers
12
views
Please make sure your database server is running at `localhost`:`5432` - Prisma Nest js -Down migration error
I am using Nest js + Prisma + Postgres in the Backend of my website. I am trying to down migrate
by following the document https://www.prisma.io/docs/guides/database/developing-with-prisma-migrate/...
0
votes
1
answer
13
views
How to mock a named nestjs Logger with ts-mockito
Our project uses nestjs with mocha, chai and ts-mockito for testing and I can't figure out how to test a named nestjs Logger.
new Logger() can be tested as expected:
describe('basic test', () => {
...
0
votes
0
answers
14
views
@nestjs/typeorm How to get current connection with v0.3.0 of typeorm in a custom decorator?
I used to have:
import { getManager } from "typeorm";
return getManager()
.count(entity, {
...where,
})
.then((count) => count < 1);
to use the current connection in a ...
0
votes
0
answers
23
views
How to generate openapi json with NX?
I am having NestJS projects in a Monorepo and NX is our build system.
I am looking for a way to compile and run a TS file at build time. The TS file has a logic to generate openapi.json file. TS file ...
-1
votes
0
answers
15
views
NestJs Caching - why use Redis?
I have only used the default NestJs Caching strategy.
What do I gain by swapping it out with Redis?
What problem solves Redis that the default caching strategy doesn't solve?
I haven't used Redis so ...
0
votes
1
answer
18
views
Nothing goes after TypeORM 0.2 to 0.3 in NestJS
I have a problem.
In my NestJS project, I updated TypeORM from version 0.2.* to 0.3.* and nothing works anymore.
/**
* Get all addresses of the user
*
* @param user User
*/
sync getAddresses(user: ...
0
votes
0
answers
13
views
Class that has nested array properties in typeorm
I'm using TypeORM with Postgresql and having trouble creating entity file with nested scheme
The records I would like returned from my database should look like this:
[{
id: 1,
name: 'john'
...
0
votes
0
answers
11
views
Mocking a File object in NestJs unit test with Jest
I recently started working with Nest.js and its built-in unit testing library Jest, while on a task to upload a .CSV file and perform some operations on it, I decided to also unit test the endpoint ...
0
votes
0
answers
17
views
Best way of Fetching of data which requires some external call
I am new to graphql and I am trying to experiement and understand it. I have a situation which I am not sure how to handle. Lets say I have Book which has fields like
name
author
price
Now, I need ...
0
votes
1
answer
19
views
Nestjs prisma global exception handler status is always 500
this is the all-exception.filter.ts:
@Catch()
export class AllExceptionsFilter implements ExceptionFilter {
constructor(private readonly httpAdapterHost: HttpAdapterHost) {}
catch(exception: ...
0
votes
1
answer
15
views
Use transaction in sequelize Bulk create with include associations
i am using sequelize into Nestjs, i am trying to insert a new contact in my contact table, i want to send a list of contacts into a bulkcreate function like this:
await this.contactModel.bulkCreate(...
0
votes
0
answers
37
views
NestJS problems with shared modules
I am trying to create a shared logging module in NestJS that can be shared between multiple micro-services.
The logging module works when it is part of the micro-service but when I extract the code to ...
0
votes
0
answers
17
views
NestJS & TypeORM addEntitiesByConnection is not a function
I'm currently working on a project that has a backend that uses NestJS and TypeORM with a Postgres db, running in Docker. It used to work fine, but now it suddenly gives this error message whenever I ...
0
votes
1
answer
30
views
nestJs FileInterceptor and DTO
I want to create upload with swagger,use DTO and save the binary in my MongoDB
My DTO is:
import { ApiProperty } from '@nestjs/swagger';
import { Expose } from 'class-transformer';
import { IsNotEmpty,...
0
votes
0
answers
14
views
Can help me set global log level in Nestjs?
I want to set the global log level in nestjs. I've only set the level of error, and the rest of the levels haven't been.
0
votes
1
answer
20
views
how i can send Json object to graphql
i am using graphql with nestjs .(typescript)
mutation syntax error shows.
even if i send single json value
rules: "{ \"==\" : \"[ { \"var\" : \"a.on\" }, true ...
1
vote
2
answers
24
views
TypeORM Entity Validators not working when E2E testing GraphQL API with SuperTest
Morning everybody!
Tech Stack: NestJS + GraphQL + TypeORM
Have a strange problem with TypeORM Entity Field validators (@IsURL() & @IsNotEmpty()) not working when running E2E tests using SuperTest ...
0
votes
0
answers
15
views
Why AccessTokenStrategy (@UseGuards(AuthGuard('jwt'))) always returns Unauthorized 401?
I'm really bad in jwt and can't understand why i always have "unauthorized" when i'm trying to logout. I use "passport-jwt" and others endpoints in my auth api works in a right way,...
0
votes
0
answers
11
views
How can I search of a word in a column in 2 diffrent repositories using one query (MySQL and TYPEORM and nestjs)
I'm using MySQL with Typeorm in nestjs the latest versions of them and I have these entities:
The shop.entity.ts:
@Entity()
export class Shop {
@PrimaryGeneratedColumn("uuid")
id: string;...
2
votes
0
answers
21
views
How to connect elastic cache Redis to Nestjs Application
I want to establish a connection with Redis to Nestjs I have searched a lot but I can not figure it out.
i establish a connection with my localhost Redis with Nestjs with CacheModule like this
...
1
vote
1
answer
17
views
Is there any way to get the list of validators used in moongoose schema?
I want to get the list of validators that is used in a moongoose schema? Something like
const userModel = {
firstName: {
type:String,
required: true
}
}
// is there any method to get validations ...
0
votes
1
answer
30
views
CORS headers missing when using Axios in NextJS
I'm using a NestJS backend with a NextJS frontend, both hosted seperately.
NestJS Backend
I enabled CORS in the backend as follows:
app.enableCors({ credentials: true, origin: process.env.FRONTEND_URL ...
0
votes
3
answers
35
views
Argument of type '{ id: string; }' is not assignable to parameter of type 'FindOneOptions<Seller>'
Using mongodb by typeorm with nestjs - create crud rest api
when trying to get data by findone() with 'id' . getting below error
TS2345: Argument of type '{ id: string; }' is not assignable to ...
0
votes
0
answers
29
views
NestJS Reading File - No Such File or Directory
I am having trouble getting my nestJS app to read my cert secret file and even a simple txt file. I am getting the error:
ERROR [ExceptionsHandler] ENOENT: no such file or directory
Below is all I ...
0
votes
0
answers
15
views
Can I use TypeOrm's FindOperators inside a base class without getting bad SQL Unknown column '_type' in 'where clause'
I am trying to write a base class for CRUD operations for "typeorm": "~0.2.45" under "@nestjs/typeorm": "~8.0.3" using node v14.19.3.
The base class looks like ...
0
votes
1
answer
26
views
Best way to share NestJS entities(or modules) between the private applications
We've been using the NestJS to build the backend service(=original project from now on). We're also going to create another NestJS application which is depending on same database with the original one ...
0
votes
0
answers
21
views
Nest js convert module from forRoot to forRootAsync
@Module({
imports: [],
providers: [SupertokensService, AuthService],
exports: [],
controllers: [AuthController],
})
export class AuthModule implements NestModule {
configure(consumer: ...
0
votes
0
answers
10
views
Nginx Directory index of 'folder path' is forbidden and SSL do handshake() failed
i have my Project in nestjs with view using pugjs for templating and i try to deploy in Nginx and tried to generate the ssl certificate
i an getting the error displayed in image
thanks in advance
0
votes
0
answers
29
views
Nestjs - Implement Azure-Ad Passport Authentication
How can I implement Azure-Ad Passport Authentication? Can't find any documentation for it, and read online that there are problems with that.
0
votes
1
answer
16
views
TypeORM looping on WhereExpressionBuilder result same value
I have a problem, I need to show all the rows containing certain tags.
on the database tags format like one,two,three
here my WhereExpressionBuilder code.
const tags = ['one','twoo','three']
...
1
vote
0
answers
23
views
Invalid greeting. response=421 Server busy, too many connections: 421 Server busy, too many connections -Nest.js Nodemailer
I'm trying to use the Nest.js MailerModule that interacts with NodeMailer to send emails with outlook smtp on localhost, before pushing it online. But evertime I run it, I get an Invalid greeting. ...
-1
votes
1
answer
18
views
How to test an exception in an Observable?
I have httpService that is an Observable, but just before returning, I'm turning it into a Promise with "lastValueFrom"
async getRandomRecipes(): Promise<BasicRecipe> {
const res =...
1
vote
1
answer
30
views
Modify response with nestjs interceptor
I have Interceptor for modify icon path like this:
@Injectable()
export class GetProgramIconInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler<any&...
0
votes
1
answer
19
views
Deploying a NestJs project on a single board computer (Raspberry or similar)
even if it seems a simple task I'm having some trouble finding a solution. I know that with Nest CLI I can use the command "nest build" in order to create a dist folder that contains the ...
0
votes
1
answer
28
views
How to access method of Project A into Project B in nodejs, i am using nestjs
i have MailEvent class and want to use SendEmail method in client project. i use NPM link to share code for client project. but i can't access this method. how can i access this method in client ...
0
votes
1
answer
15
views
Make a Nest.JS project executable but without the source code exposed
If we want to deploy our NEST.js sever on the customer's environment, how can we hide our source code preventing from the plagiarism?
0
votes
0
answers
10
views
Jest test suites fail when executed in parallel but succeed when run individually
I'm using JestJS for end-to-end testing of my NestJS API
When I run all end-to-end tests (which are split up across many files, each file contains one test suite):
'npm run test:e2e'
Multiple tests ...
1
vote
0
answers
16
views
handle multiple instances prisma warning in nestjs testing
I'm writing tests for a Nestjs API. when I run it, it gives this error:
warn(prisma-client) There are already 10 instances of Prisma Client actively running.
this is in my test where I instantiate ...
0
votes
1
answer
21
views
REST app dependency structure using NestJS
So I'm writing a pretty big RESTful web-app and I opted for NestJS. So far I like it, I like the modular structure with DI, and I find it very appropriate for a REST app.
My general structure is ...
0
votes
1
answer
25
views
Google Cloud App Engine - NestJS App deploys fine and runs instance, but can't access it
I am trying to host a NestJS application on Google App Engine. I'm using Cloud Build to deploy the app into App Engine after certain action on my GitHub repo.
Everything goes fine; the app builds and ...
0
votes
0
answers
16
views
Trying to save a zip file in nestjs
I have a backend service that returns a zip file, and a proxy service that needs to send it to the frontend. The backend service definitely sends a legit zip file, but the nestjs proxy service is ...
0
votes
0
answers
12
views
Is it possible to (correctly) use multiple Kafka brokers on NestJS hybrid application?
I'm doing some research on using multiple Kafka brokers on a NestJS hybrid application, and altough I know it's possibleI can't find the answer for wether it's not a bad practice or wrong at all to do ...
0
votes
0
answers
24
views
What is the right way to pass request data to services in nestjs?
I have many services that all need to know the tenant ID from the request (kept in JWT auth token). The request is either GRPC (jwt stored in MetaData) or Graphql (jwt stored in context.headers....