News Articles nestjs

Malformed array literal in POSTgres

I am trying to update a column in my entity which looks like : @Column(‘jsonb’, { array: true }) work_days: any; And in the postgres it looks like work_days | jsonb[] And in my repository it looks like : async updateFreelancerWorkDays(data, userId) { return this.createQueryBuilder() .update(Freelancer) .set({ work_days: data}) .where("user_id = :userId", { userId }) […]

Nest + Fastify + fasity-next + TypeOrm cannot find next() function

I am trying to initialize Nest with Fastify and Next using the fastify-next plugin, everything was okay until I integrated TypeOrm (MongoDB). When Nest loads the AppModule it throws an error that says the .next() function is not found in the fastify instance after the fastify-next plugin is initialized. Code // main.ts async function bootstrap() […]

Build TODO APIs by learning Nest Framework

The key to build any application is its architecture. Working on Node.js architecture has always been my pain area and that’s one of the main reasons why I started exploring the Nest.JS framework. In this article, I will try to share my thoughts and experience about learning the Nest.Js framework (Hint: If you are an […]

Plaid API complains on TypeScript implementation

Porting over a simple plaid node app into NestJS and TypeScript is complaining about country_codes and products. Not sure what the deal is, when I hover over country_codes I get the following type info: Specify an array of Plaid-supported country codes using the ISO-3166-1 alpha-2 country code standard. Institutions from all listed countries will be […]

Postgres Malformed array literal

I was tryin to update a field in Nestjs. But this error continuously happend so i manually inserted the data and ran the query, still getting the same error. query failed: UPDATE "freelancers" SET "work_days" = $1, "updated_at" = CURRENT_TIMESTAMP WHERE "user_id" = $2 — PARAMETERS: [{"days":[1,2],"time":{"to":8,"from":12}},"a464a517-5cf0-4640-992b-dbc8cbce9e7f"] I have my freelancer entity column work_days like […]

Sending request with text body in Postman

I am trying to send a body as content-type: text/plain but i am unable to retrieve it in my application. I am doing something like this "days": [1, 2], "time": { "to":8, "from":12 } But when i try to access it in my controller it doesn’t show anything. async testFunction(@Body() body, @Req() req) { console.log(req.body) […]

Nest JS Exception Overrides Pipe Implementation in all levels both global and local

I am implementing validation in my nestjs project and i implemented Http Exception Handler on the global scope previously . Then i Used the ValidationPipe class for input validation but its gets overridden by exception filter each time a validation fails. and works just fine once i comment excepton filter Source: JavaSript – Stack Overflow

Saving object as Text

I am trying to send a request which updates a field in database[pg]. I have a freelancer entity wit this field that needs to be updated. @Column(‘varchar’, { array: true }) work_days: string; This is my postman request : { "days": [1, 2] , "time": { "to":8, "from": 9 } } What i want is […]

Unique key not getting updated like other fields in postgres

I am working on a NestJs project and everything seems really okay until I tried to update and I discovered that a UUID I tried a change to another with is coming from a different table is not updating. I am not get any error though but obvious there is something I am not doing […]

commitlint with Husky is not working on bogus commits

create mode 100755 .husky/commit-msg create mode 100644 commitlint.config.js Getting above error on wrong commit messages. I’ve followed this tutorial to implement it Source: JavaSript – Stack Overflow

Nestjs microservice cron-tasked job with this.client.send

I have the following issue. When I am working with microservice pattern from Nestjs docs via Redis, untill I am dealing with controllers (for example from the following repo) it’s find. I have Redis launched in container and successfully sending and delivering cmd message from api-gateway to first-microservice For example, this part is sending messages […]

How can we use @Tree(‘closure-table’) in NestJs?

I want use @Tree(‘closure-table’) so I have the below method and entity: public async create(createCategoryDto: CreateCategoryDto) { try { const manager = getManager(); const category = await this.categoryRepository.create(createCategoryDto); return await manager.save(category); } catch (e) { throw e; } } And entity: import { Column, Entity, PrimaryGeneratedColumn, Tree, TreeChildren, TreeParent, } from ‘typeorm’; @Entity() @Tree(‘closure-table’) export […]

How to get multer image in backend(nest) file to on my frontend(react)?

I have a question while making the avatar image(url) in user sign up form on my project. frontend: react.js backend: nest.js First of all, I saved my avatar image in server folder with using multer. and then i want to get avatar image to my frontend but i have no idea about next step😭. code […]

Nx Monorepo NestJS TypeORM SQLite: Unable to Connect to the Database

I am creating a web application using an Nx monorepo which is going to have a NestJS backend and an Angular frontend. I want to use SQLite as database. The SQLite database file name is my_db.db which is located in the root of the repo/project. My monorepo general structure is like the following: my-project │ […]

@nestjs/swagger does not set authorization headers

Can’t authorize in a route using @nestjs/[email protected] because i dont know how to configurate the Document` in a right way and i don’t find Workable answer in authorization official docs/stackoverflow/github Im stumbled upon a problem with JWT authorization in swagger. Im using a "@nestjs/swagger": "^5.0.9" and after im getting my access-token from a public route […]

Error: Nest can’t resolve dependencies of the AwsSnsService (?)

I am trying to inject a service from one module to another module. I am keep on getting Error: Nest can’t resolve dependencies of the AwsSnsService (?). Please make sure that the argument function() {n if (klass !== Object) {n return klass.apply(this, arguments);n }n } at index [0] is available in the AwsModule context. Below […]

Locally hosted app not communicating properly with a remote backend (CORS)

The problem: I’m having trouble obtaining data from my web API. I’m testing a React app locally and I keep having CORS errors. The CORS headers seem to exist when accessing the endpoint via browser or Insomnia. But when I try to make a request via axios or fetch that’s where the it all goes […]

How Can I code a a list of dtos related in a dto?

I’m coding a Nestjs controller where I need to specific a dto to retrieve information from front end but the point is I want to do re-usable this function so I need the dto could be any dto specifiqued @UseGuards(AuthGuard) @Permissions(‘admin’) @Post(‘/pdf’) async exportDataPdf(@Query() query: GetOrdersFilterDto, @Body() body: any): Promise<any> { await this.exportDataService.exportDataPdf(query, body); return […]

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.