Questions tagged [nestjs]

NestJS, the Nest Framework, is a revolutionary tool designed to streamline the development of high-performance and scalable Node.js applications. With its innovative approach to JavaScript programming, Nest leverages the power of TypeScript and provides unparalleled support throughout the development process.

Error message stating: "A missing module (MODULE_NOT_FOUND) was detected in the nest.js code

Having a code base that runs smoothly on a Windows machine using node v10.16.3, I encountered an issue when trying to install the same code on a CentOS Linux box with node v12.16.3. The error message displayed is regarding a missing module '@angular-d ...

The compatibility issues, absence, or failure to assign property entities in NestJS Prisma

Trying to update the Postgres database with Prisma ORM in NestJS (Microservices architecture) includes allowing users to interact with invitation requests. However, encountering the error message: Argument of type 'Invitation' is not assignable t ...

What is the source of the compiler options in tsconfig.json?

Currently utilizing Typescript in NestJs, I have incorporated various packages. However, the specific package responsible for altering these settings remains unknown to me: "checkJs": false, "skipLibCheck": true Is there a method to ...

Nest may struggle with resolving dependencies at times, but rest assured they are indeed present

I've encountered a strange issue. Nest is flagging a missing dependency in a service, but only when that service is Injected by multiple other services. cleaning.module.ts @Module({ imports: [ //Just a few repos ], providers: [ ServicesService, . ...

Utilizing form data to upload images and send them back to the front end within a React js application

I am working on a project using NestJS and React JS to create an image uploader. In React, I have the following setup: const props = { onChange({ file, fileList }: any) { const fd = new FormData(); fd.append('img', fil ...

Issue with Express-session: Cookie expiration not being reset with every request

I'm currently utilizing express-session for authentication in my web application. Unfortunately, I've encountered a persistent problem where the cookie expiration time isn't being reset with each request. Here's the code snippet that I'm working with: mai ...

Is there a way to set up custom rules in eslint and prettier to specifically exclude the usage of 'of =>' and 'returns =>' in the decorators of a resolver? Let's find out how to implement this

Overview I am currently working with NestJS and @nestjs/graphql, using default eslint and prettier settings. However, I encountered some issues when creating a graphql resolver. Challenge Prettier is showing the following error: Replace returns with (r ...

Issue with setting cookie: Browser does not retain cookie after receiving successful response

I am currently working on a project that involves Angular and NestJS, but I have encountered an issue with managing cookies. After logging in through the Angular frontend, the server responds with a Set-Cookie header containing the JWT token. However, for ...

Issue with nestjs build due to ts-loader module in dev-dependency

I've encountered a Module Error with ts-loader during a docker build ERROR [6/6] RUN nest build 3.9s ------ > [6/6] RUN ...

Why is NestJs having trouble resolving dependencies?

Recently delving into NestJs, I followed the configuration instructions outlined in https://docs.nestjs.com/techniques/database, but I am struggling to identify the issue within my code. Error: Nest cannot resolve dependencies of the AdminRepository ...

Best practices for implementing "Event Sourcing" in the NestJS CQRS recipe

I've been exploring the best practices for implementing "Event Sourcing" with the NestJS CQRS recipe (https://docs.nestjs.com/recipes/cqrs). After spending time delving into the features of NestJS, I have found it to be a fantastic framework overall. Howe ...

Guide: Ensuring the validity of an object retrieved from a database with Nest.js class-validator

When activating a user, I need to ensure that certain optional data in the database is not empty by using class-validator dto. So far, my controller level validations for body, query, and all other aspects have been successful. The DTO file contains vali ...

Getting the Hostname in a NestJS Controller Function

I am currently utilizing a NestJS application to serve a REST-API. Is there a way for me to obtain the current Hostname within a controller? This is my controller function: async find(@Param('uuid') uuid: string, @Req() req: Request): Promise&l ...

Retrieve request header in Nest.js Passport local strategy

Is there a way to retrieve the request headers in passport local strategy? My objective is to establish a separate database for each entity using mongodb, and I need to determine the subdomain before authentication in order to connect to the correct data ...

Leveraging BigCommerce as a Headless solution paired with Nextjs on the front end, and Nestjs on the backend

As a newcomer to the world of BC, I find the documentation a bit confusing. I am interested in utilizing BC APIs with Nextjs and Nestjs. The goal is to develop a traditional web application where Nestjs on the server communicates directly with BC APIs, w ...

Can you explain the functionality of `property IN array` in the TypeORM query builder?

I'm looking to filter a list of entity ids using query builder in an efficient way. Here's the code snippet I have: await this._productRepo .createQueryBuilder('Product') .where('Product.id IN (:...ids)', { ids: [1, 2, 3, 4] ...

Failure when running npm start command in Nest js

After setting up a fresh Nest js on a new EC2 machine, I encountered an error when trying to run it for the first time. The error message indicated that the npm install process failed abruptly without any visible error: ubuntu@ip-172-31-15-190:~/projects/m ...

Utilizing interface in NestJS for validating incoming request parameters

My goal is to utilize the interface provided by class-validator in order to validate a specific field in the incoming request body. Here's the interface structure: export enum Fields { Full_Stack_Dev = 'full stack dev', Frontend_Dev = 'frontend dev', ...

Loading handlebar templates for sending emails with nodemailer from a remote server is simple and straightforward

I currently have a nestjs application with a POST /email endpoint that utilizes nodemailer to send emails based on handlebar templates. The template used depends on the selection made in the API call (template=xxx). For example, http://localhost:3000/< ...

Using NestJS to pass request and response parameters

I have a function in my services set up like this: ` @Injectable() export class AppService { getVerifyToken(req: Request, res: Response) { try { let accessToken = process.env.ACCES_TOKEN_FB; let token = req.query["hub.verify_t ...

Can a new class be created by inheriting from an existing class while also adding a decorator to each field within the class?

In the following code snippet, I am showcasing a class that needs validation. My goal is to create a new class where each field has the @IsOptional() decorator applied. export class CreateCompanyDto { @Length(2, 150) name: string; @IsOptional( ...

Disabling breakpoints without bounds during TypeScript debugging in Visual Studio Code

While working on my Ubuntu machine using VS Code to debug a Nest.js TypeScript project, I am encountering issues with unbound breakpoints that are not being hit. Despite making various changes in the launch.json and tsconfig.json files, as well as trying o ...

Make sure to empty the event loop before shutting down the Node.js server

I am currently utilizing a Node.js server with the NestJS framework which involves image processing that takes approximately 30 seconds to complete. The workflow is as follows: request -> image processing (~30s) -> response My goal is to implement a mech ...

What is the best way to synchronize API definitions between the server and client using TypeScript?

My setup involves a server (TypeScript, NestJS) and a client (TypeScript, Angular) that communicate with each other. Right now, I have the API response DTO classes defined in both the server to output data and in the client to decode the responses into a ...

What impact does manually serializing gRPC request and response objects have on performance?

I am aiming to establish communication with a NodeJS microservice by sending and receiving data. The challenge lies in the fact that both my request and response objects have dynamic components - fields containing a union of 'string' and 'nu ...

NestJS Exporting: Establishing a connection for PostgreSQL multi tenancy

I have been working on implementing a multi tenancy architecture using postgres. The functionality is all in place within the tenant service, but now I need to import this connection into a different module called shops. Can anyone provide guidance on how ...

Learn how to generate specific error messages based on the field that caused the failure of the @Column({ unique: true }) Decorator. Error code 23505

Hey there! I'm currently facing an issue while trying to handle Sign Up exceptions in my code. I want to inform the user if their username OR email is already in use. Although using the decorator @Column({ unique: true}) allows me to catch error 23505 ...

Establishing a pair of separate static directories within Nest

I am looking to utilize Nest in order to host two static applications. Essentially, I have a folder structure like this: /public /admin /main Within my Nest application, I currently have the following setup: app.useStaticAssets(join(__dirn ...

Can you explain the purpose of connectMicroservice and startAllMicroservicesAsync functions in nestjs?

While looking through the codebase, I came across connectMicroservice and startAllMicroservicesAsync in an application using Nest. Could someone please clarify what these functions are used for? I attempted to research them in the official Nest documenta ...

Protecting NestJS API for Angular App with Auth0

Currently, I am working on an Angular application that utilizes NestJS as the backend. Authentication is functioning properly in the Angular app, where users can log in to Auth0 and are redirected back to our app seamlessly. The /token call in the network ...

A guide on renewing authentication tokens in the Nestjs framework

import { ExtractJwt, Strategy } from 'passport-jwt'; import { AuthService } from './auth.service'; import { PassportStrategy } from '@nestjs/passport'; import { Injectable, UnauthorizedException } from '@nestjs/common&apo ...

Why does the Node Nestjs watch feature consistently shatter?

Just diving into node.js development with the nestjs framework and encountered a persistent issue. Every time I run the following command in my package.json: npm run start:debug I face an error after making some changes to my code, causing it to break une ...

Obtaining the true client IP address in a Dockerized Next.js and Nestjs application instead of the Nginx Container's IP Address | Utilizing X-Forwarded-For

I have successfully Dockerized both Next.js 13 (front end) and Nestjs (API), with a reverse proxy set up using the nginx-proxy image. Below is my configuration in the docker-compose.yml: api: image: gidgud/my:api container_name: api ports: ...

Issue: Debug Failure. Invalid expression: import= for internal module references should have been addressed in a previous transformer

While working on my Nest build script, I encountered the following error message: Error Debug Failure. False expression: import= for internal module references should be handled in an earlier transformer. I am having trouble comprehending what this erro ...

Warning: Outdated version detected during NestJS installation on npm

Whenever I attempt to download NestJS using the command npm i -g @nestjs/cli, I encounter the following issue: npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a6d5c9d3d4c5c3cb8ed7cbc1ccdcdffccdc3d0"><?[ ...

Nestjs: Step-by-step guide to removing a specific application from a Nestjs monorepo using nest/cli

Is there a method to delete a specific app within a nestjs monorepo using the nest/cli? I have searched through the documentation and developer forums but cannot seem to find a solution. ...

We're sorry, but Nest is unable to fulfill the dependencies of the movieModel. Kindly ensure that the DatabaseConnection parameter at index [0] is accessible in order for the process

I am facing an issue while using mongoose in Nest.js The error message I received is as follows: Nest can't resolve dependencies of the movieModel (?). Please ensure that the argument DatabaseConnection at index [0] is available in the MongooseModule con ...

Guide to releasing a NestJs library on npm using the nrwl/nx framework

Struggling with creating a publishable NestJS library using NX. Despite reading numerous documentations, I still can't figure it out. I've developed a NestJS library within an NX monorepository and now I want to publish just this library on NPM, ...

What could be the reason for encountering the error message "Unable to define properties" while working with NestJs?

Currently, I am facing an issue while trying to assign a value to csrfToken within the session: import { v4 as uuidv4 } from 'uuid'; import * as session from 'express-session'; @Injectable() export class CsrfMiddleware implements NestM ...

The FOR UPDATE clause is not functioning as intended in the SELECT query

I have been working on isolating my database to prevent multiple servers from reading or updating data in the same row. In order to achieve this, I have structured my query like so: SELECT * FROM bridge_transaction_state as bridge WHERE bridge.state IN ('T ...

The variable isJoi has been set to true but there is an error due to an unexpected

I am currently developing a NestJs backend on multiple machines. One of the machines is experiencing issues with the @hapi/joi package. When running the NestJs application in development mode on this specific machine, I encounter the following error: PS C ...

The exclude option in Nest JS middleware does not prevent the middleware from running on excluded routes

I'm having an issue with excluding certain routes from the middleware. The .exclude option doesn't seem to be working as expected, as the middleware is still being applied to the excluded routes. Here is the code for the Middleware: https://i.stack.imgur. ...

Using NestJs for serverless functions with MongoDB is causing an excessive number of connections to be

In our project, we are utilizing nestjs for lambda functions that communicate with mongodb for data storage. Our implementation involves using the nestjs mongoose module. However, upon deployment, a new set of connections is established for each invocation ...

Using TypeORM with a timestamp type column set to default null can lead to an endless loop of migrations being

In my NestJs project using TypeORM, I have the following column definition in an entity: @CreateDateColumn({ nullable: true, type: 'timestamp', default: () => 'NULL', }) public succeededAt?: Date; A migration is generated with the corre ...

After upgrading from version 8 to 9, Nest is struggling to resolve the dependencies of the XXX component

My Nestjs application has stopped working after upgrading from version 8 to 9.2.1 Following the upgrade, I am encountering the error message: "Nest can't resolve dependencies of the XXX" in all my resources. Prior to the upgrade, everything was functionin ...

Exploring NestJS: Leveraging the @Body() Decorator to Retrieve Request Body Data

import { Controller, Post, Body } from '@nestjs/common'; import { MyService } from 'my.service'; import { MyDto } from './dto/my.dto'; @Controller('my-route') export class MyController { constructor(private readonly _myService: MyService) {} @Po ...

Running Code Following Response Completion in NestJS

Objectives: The goal is to execute code after the response has been completely processed and successfully sent out. After consulting the documentation, I attempted the following approach: @Injectable() export class LoggingInterceptor implements NestInterc ...

The issue of resolving NestJs ParseEnumPipe

I'm currently using the NestJs framework (which I absolutely adore) and I need to validate incoming data against an Enum in Typscript. Here's what I have: enum ProductAction { PURCHASE = 'PURCHASE', } @Patch('products/:uuid') async patchProducts( @P ...

Encountering issues when trying to build a Nestjs app with node-crc (rust cargo) in Docker

I am encountering an issue with building my Nest.js app using Docker due to a dependency called "node-crc" version "2.0.13" that fails during the docker build process. Here is my Dockerfile: FROM node:17.3.1-alpine RUN curl https://sh.rustup.rs -sSf | sh ...

Is there logic in developing a web application using a combination of a NestJS backend and Next.js frontend, along with authentication features?

Currently, I am embarking on the journey of developing a web application using React and Next.js. With my previous experience in backend development using NestJS, I decided to integrate it into this project as well. However, I am unsure if separating the f ...

The JWT token will expire if the user logs in from a different browser

My application generates a JWT token for the user when they log in, but I am facing an issue. I want the user to be automatically logged out from their first device or browser when they log in from another one. Unfortunately, I have not been able to find ...

Using NestJS to populate data will only populate the first element

I have a Mongoose schema in NestJS structured like this: ... @Prop() casinoAmount: number; @Prop() gameHyperLink: string; @Prop() casinoHyperLink: string; @Prop({ type: Types.ObjectId, ref: 'Game' }) games: Game[]; } I'm trying to create ...

I am having trouble with the 'Kind namespace not found' error and would appreciate assistance

After upgrading NestJs to the latest version (8.3.1) from 7.5, I managed to resolve most of the issues that came up. However, there is one stubborn issue that I just can't seem to get rid of. The complete error message reads as follows: node_modu ...

Utilize the UserService in NestJs to enhance security within the RolesGuard functionality

In my application, I have a module called UserModule that exports the UserService. Here is an example of how it is done: @Module({ imports: [ MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]), MongooseModule.forFeature([{ name: ...

Tips on extracting value from a pending promise in a mongoose model when using model.findOne()

I am facing an issue: I am unable to resolve a promise when needed. The queries are executed correctly with this code snippet. I am using NestJs for this project and need it to return a user object. Here is what I have tried so far: private async findUserB ...

Retrieve the instance from the provider using its unique key without needing to inject its dependencies

I created a custom class called PermissionManager, which takes a list of Voter interfaces as an input in its constructor. export interface Voter { vote(): bool; } export class PermissionManager { constructor(private readonly ...

What causes the distinction between entities when accessing objects through TestingModule.get() and EntityManager in NestJS?

Issue: When using TestingModule.get() in NestJS, why do objects retrieved from getEntityManagerToken() and getRepositoryToken() refer to different entities? Explanation: The object obtained with getEntityManagerToken() represents an unmocked EntityManag ...

struggling with configuring dependency injection in NestJS and TypeORM

Struggling with integrating nestjs and typeorm for a simple CRUD application, specifically facing issues with dependency injection. Attempting to modularize the database setup code and import it. Encountering this error message: [ExceptionHandler] Nest ...

Troubleshooting the creation of migration paths in NestJS with TypeORM

After diligently studying the NestJS and TypeORM documentation, I have reached a point where I need to start generating migrations. While the migration itself is creating the correct queries, it is not being generated in the desired location. Currently, m ...

I am looking for a way to convert the date format from "yyyy-MM-dd" to "dd-MM-yyyy" in NestJs

I need help with changing the date format from "yyyy-MM-dd" to "dd-MM-yyyy". Currently, my entity code looks like this: @IsOptional() @ApiProperty({ example: '1999-12-12', nullable: true }) @Column({ type: 'date', nullable: true }) birthDate?: Date ...

A guide on determining the return type of an overloaded function in TypeScript

Scenario Here is a ts file where I am attempting to include the type annotation GetTokenResponse to the function getToken. import { ConfigService } from '@nestjs/config'; import { google, GoogleApis } from 'googleapis'; import { AppCon ...

Error Message: Unable to Locate File in NestJSExplanation: The specified file could not

I'm encountering an issue with my nestJS app not being able to read my cert secret file or even a basic text file. The error message I'm receiving is: ERROR [ExceptionsHandler] ENOENT: no such file or directory Here's the code snippet where I use fs to ...

Looking to integrate Nestjs with additional Redis functionalities?

I recently set up a nestjs backend with redis for caching by following the instructions in the official documentation . To achieve this, I utilized the cache-manager-redis-store package and included the necessary code in my app.module.ts file as shown bel ...

NX combined with Nest.js and TypeORM, further enhanced with Webpack and Migrations

Recently, I embarked on a project using NX (Nest.js + Angular) and set up TypeORM for database configuration. While everything runs smoothly in "serve" mode, I found myself struggling with configuring migrations. In a typical Nest.js project, all files in ...

Using NestJS to import and inject a TypeORM repository for database operations

This is really puzzling me! I'm working on a nestjs project that uses typeorm, and the structure looks like this: + src + dal + entities login.entity.ts password.entity.ts + repositories ...

What are the best practices for implementing serialization in NestJS?

Recently, I delved into a fresh NestJs project and encountered a hurdle while trying to integrate serialization. The goal was to transform objects before sending them in a network response. Initially, everything seemed to be working smoothly until I attemp ...

What is the method for defining a constant data type with a class property data type in typescript?

I've been working on developing a nestjs API and have been using classes to define my entities. For instance, I have created a Customer entity as shown below: export class Customer { id: number; name: string; } Now, while working on my Customer Co ...

Guidelines for Nestjs class-validator exception - implementing metadata information for @IsNotIn validator error handling

I have a NestJs data transfer object (dto) structured like this import { IsEmail, IsNotEmpty, IsNotIn } from 'class-validator'; import { AppService } from './app.service'; const restrictedNames = ['Name Inc', 'Acme Inc&ap ...

Exploring the power of NestJS integration with Mongoose and GridFS

I am exploring the functionality of using mongoose with NestJs. Currently, I am leveraging the package @nestjs/mongoose as outlined in the informative documentation. So far, it has been functioning properly when working with standard models. However, my p ...

Tips for securely encrypting passwords before adding them to a database:

While working with Nest.Js and TypeORM, I encountered an issue where I wanted to hash my password before saving it to the database. I initially attempted to use the @BeforeInsert() event decorator but ran into a roadblock. After some investigation, I disc ...

Utilize the provider within the decorator function

Essentially, the challenge I am facing is passing an authService to the "verifyClient" function within the @WebSocketGateway decorator. Here is how it should look: @WebSocketGateway({ transports: ['websocket'], verifyClient: (info: { req: IncomingMessa ...

Executing a NestJs cron job at precise intervals three times each day: a guide

I am developing a notifications trigger method that needs to run three times per day at specific times. Although I have reviewed the documentation, I am struggling to understand the regex code and how to customize it according to my requirements! Current ...

Troubleshooting problem with NestJS Swagger

I'm encountering an issue while attempting to incorporate swagger into my NestJS application. The error message I am receiving is as follows: (node:78477) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined at lodash_1.m ...

Testing a NestJS service with multiple constructor parameters can be done by utilizing various techniques such as dependency

Content When testing a service that needs one parameter in the constructor, it's essential to initialize the service as a provider using an object instead of directly passing the service through: auth.service.ts (example) @Injectable() export class ...

Encountering an error while attempting to connect to the NestJs Google VM Server from a Firebase-hosted NextJs application

A NestJS server has been set up as follows: import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import * as fs from 'fs' import * as https from 'https' import * as express from 'express' import * as http from 'http' import ...