Category : nestjs

i’m building an application using Nest Js and TypeOrm. I have a many to many relation between ShoppingList and Item, like this: ShoppingList @Entity() export class ShoppingList { @PrimaryGeneratedColumn(‘uuid’) id: number; @Column() name: string; @CreateDateColumn({ name: ‘created_At’ }) createdAt: Date; @Column({ default: ‘open’ }) status: ‘completed’ | ‘cancelled’ | ‘open’; @ManyToOne(() => User, (User) => ..

Read more

copy the last position of an array, and modify the object that received the last value, but it ends up also modifying the last position, leaving the two objects the same. const visitOfTheLunch = visitMounting[visitMounting.length – 1]; visitOfTheLunch.visitPoint.name = ‘almoƧo’; visitOfTheLunch.lunch = true; visitOfTheLunch.waypoint.estimatedArrival = visitMounting[visitMounting.length – 1].waypoint.estimatedDeparture; const backHourOfTheLunch = new Date(visitMounting[visitMounting.length – 1].waypoint.estimatedDeparture); ..

Read more

I create a guard that are like these import { Injectable, CanActivate, ExecutionContext } from ‘@nestjs/common’; import { AuthService } from ‘./auth.service’; @Injectable() export class CompanyGuard implements CanActivate { constructor(private readonly authService: AuthService) {} async canActivate(context: ExecutionContext): Promise<boolean> { const request = context.switchToHttp().getRequest(); const token = request.headers[‘token’]; if (token) { const company = await this.authService.validateToken(token); ..

Read more

On my local machine, my nestjs application is running on port 3000 and I have one controller with two endpoints: @Get() getAll() { return this.httpService.get(‘https://localhost:3000/something’) } @Get(‘something’) getSomething() { return [1, 2, 3]; } When I try to run the getAll endpoint, I am getting Error: unable to verify the first certificate. I understand that ..

Read more

I’m new to nestJs and I needed to add role based access to the application so I followed the documentation but in the execution context user doesn’t exist. I can’t seems to find the problem here’s the github repo if you need to seem more code: https://github.com/anjula-sack/slinc-backend roles.guard.ts import { Injectable, CanActivate, ExecutionContext } from ..

Read more

I have generated certificates using below commands. openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 And I am using it in nest js as following. const httpsOptions = { key: fs.readFileSync(‘./secrets/key.pem’), cert: fs.readFileSync(‘./secrets/cert.pem’), }; const app = await NestFactory.create(AppModule, { httpsOptions, }); await app.listen(3000); And I am getting below error. What wrong ..

Read more