News Articles nestjs

NestJS How to get result of web socket stream into browser or postman

I’m developing NestJS App which creates a WebSocket to Binance API. I want to get stream output into browser window or postman. But now I can get stream output only in the console. I can’t understand how to send these streams in the browser. Also, I tried to return results with Promises and got only […]

Implementing Onion architecture in NestJS

Whatโ€™s Onion architecture? As shown in the picture, onion architecture is a way to structure the code by dividing it into domain-driven design layers. each layer can only access the layer below it throw its interfaces, and then using the dependency inversion principle each interface will be replaced with its class. Onion Architecture leads to […]

Axios is returning undefined

My API is returning proper data when I am requesting from Postman. Even API is getting properly called from React, I checked using console.log inside the controller, but I am always getting undefined response. I am not sure what the mistake is. const submit = async (e: SyntheticEvent) => { e.preventDefault(); const response = await […]

Sending email with SendGrid in NestJS

TLDR To use SendGrid in NestJS project, we simply use official mailer module from NestJS (https://github.com/nest-modules/mailer). Then setup the mailer configuration with SendGrid SMTP. But, in this post I will share you how to use SendGrid API as a NestJS service. So you can have more control of delivering your email to the client. Setup […]

Problems connecting PostgreSQL with NestJS

Iยดm trying to connect a NestJs App with PostgreSql and Iยดve the following error message in the terminal: role ‘paul’ does not exist. How can I solve that? Thanks in advance. Source: JavaSript – Stack Overflow

nestjs typeorm / How to find row with many to many relation column?

chatting_room.entity.ts @InputType("Chatting_Room", { isAbstract: true }) @ObjectType() @Entity() export class Chatting_Room { //… @ManyToMany((type) => User, (user) => user.chatting_rooms, { nullable: true, onDelete: "SET NULL", }) @Field((type) => [User], { nullable: true }) participants: User[] //… } chatting_rooms.resolver.ts @Resolver((of) => Chatting_Room) export class Chatting_RoomsResolver { constructor(private readonly chatting_roomsService: Chatting_RoomsService) {} // … @Query((returns) => Chatting_Room_List_Output) […]

Heroku saying 404 (Not Found) but working after a few refreshes

I have a nestjs app running in heroku, hosting a vue app as static files. The problem here is, the first time I enter the site, it shows me a blank screen with an 404 error to the vue static files. But, when I refresh the page a few times (like 5 or 10) everything […]

how do i solve the "statements are not allowed in ambient contexts" error

I am working on a small project which in itself has a backend project and a front end project in it. I was using a module called ‘ml-random-forest’ in frontend project but because the module’s extensive calculation would freeze the UI , i decided to take the calculation to backend project and call it via […]

I want to find central point between clusters

I have project which built by NestJs and I want to change my some datas in every 24 hours, I’ve decided to use CronJob for that. But when I run my project by pm2(on different clusters), CronJob works once for every cluster and totally it works for cluster count (if I have 8 cluster, it […]

Heroku deploy backend Nestjs + React js as frontend build not succeeding

After hours of reading this tricky build for Heroku using nestjs as backend and reactjs as frontend separately with MySQL still react app does not succeed building into heroku, failing "react-scripts: not found" which I have copy from the devdependencies to dependencies. I would like some suggestions/guidance on the clear steps from the react part […]

Authentication working fine in swagger but responding as unauthorised in frontend app,though it is storing jwt token in the cookie

here is my auth.controller.ts import { Body, Controller, Get, Post, Req, Res, UnauthorizedException, ValidationPipe } from ‘@nestjs/common’; import { ApiBadRequestResponse, ApiCreatedResponse, ApiForbiddenResponse, ApiOkResponse, ApiTags, ApiUnauthorizedResponse } from ‘@nestjs/swagger’; import { User } from ‘src/interfaces/user.interface’; import { AuthService } from ‘./auth.service’; import { AuthCredentials } from ‘./dto/auth-credential.dto’; import { Response,Request } from ‘express’; import { JwtService […]

Typescript monkey patching doesn’t work for String

I create a new interface for String to add some utility methods using the technique of Monkey-patching. interface String { toCamelCase(): string; } String.prototype.toCamelCase = function (): string { return this.replace(/[^a-z ]/gi, ”).replace( /(?:^w|[A-Z]|bw|s+)/g, (match: any, index: number) => { return +match === 0 ? ” : match[index === 0 ? ‘toLowerCase’ : ‘toUpperCase’](); }, […]

The ultimate collection of production-ready NestJS Boilerplate

The ultimate collection of production-ready and flexible NestJS Boilerplate. ๐Ÿš€ NestJS framework boilerplate with: ๐Ÿ“ฑ NestJS โ€” latest version ๐ŸŽ‰ TypeScript – Type checking โš™๏ธ Dotenv – Supports environment variables ๐Ÿ— Authentication – JWT, RSA256 ๐Ÿฌ Authorization – RBAC, CBAC ๐Ÿช TypeORM – Database ORM ๐Ÿช PostgreSQL – Open-Source Relational Database ๐Ÿง  Configuration – Single […]

Creating GraphQL Api Using NestJS For Multiple Databases

About GraphQL In recent years GraphQL has become very popular due to major advantages it offers against well known REST. Briefly, It eliminates over fetching & under fetching problems in REST With GraphQL, we don’t need to version or api as in REST GraphQL imposes an opinionated structure which easily leads to standardization whithin teams […]

Stroing multiple field of address in entity class

Hi I need to store multiple adress like address1, address2 and zipcode etc. Should I declare all the fields as individual. for eg class A{ // many fields Address1:string; Address2:string; zipCode:number; city:String; } or is there any better way to declare them in entity class. I have been told to create entity classes using best […]

Use RESTful API with and without JWT authentication

I have a web application with Angular front-end and a back-end developed using the Nest.JS framework. The back-end RESTful API endpoints are secured with an SSO and JWT authentication. Using the same web application I created a desktop application with the help of the NW.JS. The application setup is successful and can run on the […]

how to mock variable inside function typeorm nestjs

I want to test function that do .save into 2 table but in 2nd query I have to use id from 1st query here is my service async createBoth(createInput: CreateInput): Promise<SomeThing> { const data = await this.dataRepository.create(createInput); const data2 = { dataId: data.id, someInfo: ‘test’ }; await this.data2Repository.create2(wallet); } as you see in my function […]

How to make client side user persist across page refreshes and navigations using Nest.js and JWT

I am currently working on a small piece of a larger project using Nest and React. The server-side auth has already been completed using JWT. We’ve already built out the login function. See below code snippet: import * as React from ‘react’; import Button from ‘@material-ui/core/Button’; import Grid from ‘@material-ui/core/Grid’; import Paper from ‘@material-ui/core/Paper’; import […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.