News Articles nestjs

How to server static files in conteinerized nestjs server

My current setup is this. NestJS server with some functionality and ServeStaticModule serving a React application. When I run the server on my host machine everything works as expected. However, after containerizing my server the functionality works fine, but I get ERR_CONNECTION_RESET when trying to GET the React app. I understand that this is due […]

NPM Error SSL routines:ssl3_get_record:decryption failed or bad record mac npm

I’m trying to run my React JS and NEST JS application. I got the code from my work but after I clone it and try to npm install, it shows error 19072:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:c:wsdepsopensslopensslsslrecordssl3_record.c:677 I tried to find similar answer and all but I couldn’t find the solution for my npm […]

Unit test failing on NestJs-Jwt auth api

I am trying to develop a unit test for my nestjs auth api, I am new to TDD and its a comparatively simple API I started with nestjs. A basic CRUD api with jwt auth. The first unit test I am trying to perform is on my user controller.Here is the code for my users.controller.ts: […]

React GraphQL File upload

I am trying to upload a file using an apollo-graphql hook from a react front end. const [createAppLink] = useCreateAppLinkMutation(); console.log(thumbnail); createAppLink({ variables: { name: data.name, redirect: data.redirect, thumbnail: thumbnail }, }); The output of the console.log shows that thumbnail, (my image) exists. However, when I check the request tab on the network, thumbnail is […]

React GraphQL File upload

I am trying to upload a file using an apollo-graphql hook from a react front end. const [createAppLink] = useCreateAppLinkMutation(); console.log(thumbnail); createAppLink({ variables: { name: data.name, redirect: data.redirect, thumbnail: thumbnail }, }); The output of the console.log shows that thumbnail, (my image) exists. However, when I check the request tab on the network, thumbnail is […]

NestJS dependency injection and TransformPipe

I’ve created a module A, that has an exported provider AService. Module B imports module A and has an exported BTransformPipe provider, that uses AService. Now, my understanding is, that when I import module B in module C, I should be able to use BTransformPipe in controller declared in module C, without declaring any further […]

Form Data in React Native

I log Form Data in React Native received {"_parts": []} After append to form received {"_parts": [["files", [Object]]]} Server don’t received files How do I handle file upload Source: React – Stack Overflow

MongoDB and class-validator unique validation – NESTJS

TL;DR I am trying to run mongoose query in my validator Hello, I am trying to make a custom decorator which throws an error if a value for that field already exists. I am trying to use the mongoose model inside the class that validates the route. Unlike in resolver/controller, @InjectModel() does not work in […]

Compilation issues in Nest.js when changes made in a service.ts file

I am working on a Nest.js project and this is what I have in the automobile.service.ts import { Injectable } from ‘@nestjs/common’; import { InjectRepository } from ‘@nestjs/typeorm’; import { Car } from ‘./entities/car.entity’; import { Repository } from ‘typeorm’; import { CreateAutoDto } from ‘./dto/create-auto.dto’; import { UpdateAutoDto } from ‘./dto/update-auto.dto’; export class AutoService […]

Filter Get method output in Postman

I’m working with NestJS and MongoDB along side with Postman. My issue is: i have a Get method where i can select the user info by its _id. So it displays like this on Postman: { "weight": [], "_id": "6150896e27415fbfb0d37b8f", "password": "hamon", "email": "[email protected]", "name": "Joseph Joestar", "__v": 0 } But how do I set […]

Building CRUD API with NestJs – Write First API.

Part II In Part I, we created nestjs project and created a database and then integrated Mikro-Orm. In this part we are going to create entities and start writing APIs. We are first going to start with User module. We are going to structure our project like user folder will contain controller, service, repository, entities […]

Entering values in a many-to-many relationship : NestJS

I have a table called Items and a table called Categories. Between them there is a many to many relationship meaning one item can belong to many categories, and also one category can have many items in it. Image view: I am using NestJS with TypeORM. My issue is entering an Item in a database […]

How to fix Typescript CannotDetermineTypeError

Here is my code Nestjs mongoose test.schema.ts @Schema({ timestamps: true }) export class Tests { @Prop({ required: true, index: true }) testid: number; @Prop({ required: false }) extra_id: string | number; @Prop({ required: false }) points: number; } for this, I’m getting below error, CannotDetermineTypeError: Cannot determine a type for the "Tests.extra_id" field (union/intersection/ambiguous type […]

Build fast and customizable admin panel with NestJS.

All the steps described are in this repo. Intro NestJS is a framework for building efficient, scalable Node.js server-side applications. With nestjsx/crud we can add CRUD functions quickly and effortlessly on this framework. In this article, we will prepare a simple job-posting application. We will also use the refine framework for the admin panel. The […]

Extract args from context nestjs-graphql

I have this below resolver, @ResolveField() async config(@Parent() pet: Pet, @Context() ctx, @Info() info): Promise<CourseConfig> { return await this.petService.getConfig(syllabus, ctx, info); } How can I get args inside petServic.getConfig()? I know I can use @Args() decorator. But I want to extract them from context or info. I tried below method, const args = GqlExecutionContext.create(context).getArgs(); But, […]

Starting with nestjs [closed]

I am a newbie to nestjs framework. Could anyone guide what frontend technologies can be used to create ui in nestjs. Can we implement nestjs with any other languages or it can only be implemented with js framework. Which database would best suit it’s environment. Source: JavaSript – Stack Overflow

PART 0: Fundamentals of NEST.js

Hi there, this is PART 0 of my NEST.js series. In this chapter I will explain the fundamentals of NEST.js, what it is and explain a bit of how it is structured. Therefore we use the provided CLI to create a brand new project. Afterwards we are going through each generated file and what purpose […]

Connecting Heroku Postgres with NestJS Backend

Hi all! 👋 This is my first article on here. In this article I’ll show you how you can connect a postgres database to your backend api, and how to deploy it on heroku. This is not a tutorial for NestJS so i assume that you know at least the basic. If you found this […]

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.