nestjs

How to control cache in Nestjs?

柔情痞子 提交于 2020-08-27 12:29:08
问题 I read the doc of nestjs recently, and learned something from it. But I found something that puzzled me. In Techniques/Caching, the doc shows me to use a decorator like @UseInterceptors(CacheInterceptor) on a controller to cache its response (default track by route). I wrote a testcase and found it's useful. But I didn't find any explanation to show how to clean the cache. That means I have to wait for the cache to expire. In my opinion, a cache store must provide an API to clear the cache by

Getting the respsonse: "INVALID_ARGUMENT: Project id 'X' , is malformed

久未见 提交于 2020-08-20 11:31:34
问题 I'm trying to connect to google firestore and for some reason my process.env.FIREBASE_PROJECT_ID keeps spitting out the error: @firebase/firestore: Firestore (7.17.1): Connection GRPC stream error. Code: 3 Message: 3 INVALID_ARGUMENT: Project id 'name-of-project', is malformed: it either contains invalid characters or is too long. Look at https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects for instructions in how to get a project's id. [2020-08-04T23

How to fix TypeError: Cannot read property 'post' of undefined on Axios with Nestjs cronjob

帅比萌擦擦* 提交于 2020-08-10 19:37:15
问题 I tried using cron scheduler to get authentication token every 15 sec(Test purpose) the cron is supposed to call the auth endpoint but I got Exception has occurred: TypeError: Cannot read property 'post' of undefined @Cron(CronExpression.EVERY_15_SECONDS) async handleCron() { //const Primetimeauth = this.PrimetimeAuth() const primeAuth = await this.httpService.post('https://clients.com/api/auth', { "username": process.env.username, "password": process.env.password }).toPromise(); if

How to fix TypeError: Cannot read property 'post' of undefined on Axios with Nestjs cronjob

佐手、 提交于 2020-08-10 19:36:34
问题 I tried using cron scheduler to get authentication token every 15 sec(Test purpose) the cron is supposed to call the auth endpoint but I got Exception has occurred: TypeError: Cannot read property 'post' of undefined @Cron(CronExpression.EVERY_15_SECONDS) async handleCron() { //const Primetimeauth = this.PrimetimeAuth() const primeAuth = await this.httpService.post('https://clients.com/api/auth', { "username": process.env.username, "password": process.env.password }).toPromise(); if

NestJS with Apollo DataSource

核能气质少年 提交于 2020-08-10 18:50:07
问题 I have been trying to re-create the Apollo tutorial with NestJS. But when I try using apollo-datasource-rest with NestJS, it fails when fetching data from the external data source with the following error: [Nest] 29974 - 07/14/2020, 9:33:20 PM [ExceptionsHandler] Cannot read property 'fetch' of undefined +125971ms TypeError: Cannot read property 'fetch' of undefined It seems as if the data source class in not being injected properly in the resolver, but I can't figure out why? // The data

NestJs update Many-To-Many relation with join table

半城伤御伤魂 提交于 2020-08-10 04:52:05
问题 I have two entities - Property and Owner. One Property can have a lot of Owners and Owner can have a lot of Properties. For join use property_owner table. How to update this many-to-many relation using NestJS/TypeORM? @Entity('property') export class Property extends EntityModel { @Column({ length: 255, nullable: false }) name: string; @ManyToMany(type => Owner, { cascade: true }) @JoinTable({ name: 'property_owner', joinColumn: { name: 'propertyId', referencedColumnName: 'id'},

NestJs update Many-To-Many relation with join table

℡╲_俬逩灬. 提交于 2020-08-10 04:51:59
问题 I have two entities - Property and Owner. One Property can have a lot of Owners and Owner can have a lot of Properties. For join use property_owner table. How to update this many-to-many relation using NestJS/TypeORM? @Entity('property') export class Property extends EntityModel { @Column({ length: 255, nullable: false }) name: string; @ManyToMany(type => Owner, { cascade: true }) @JoinTable({ name: 'property_owner', joinColumn: { name: 'propertyId', referencedColumnName: 'id'},

NestJs: How to have Body input shape different from entity's DTO?

☆樱花仙子☆ 提交于 2020-08-09 23:56:53
问题 I've a DTO for my Photo and Tag object that looks like this: export class PhotoDto { readonly title: string readonly file: string readonly tags: TagDto[] } export class TagDto { readonly name: string } I use the PhotoDto in my photo.service.ts and eventually in the photo.controller.ts for the creation of Photo: // In photo.service.ts async create(createPhotoDto: PhotoDto): Promise<PhotoEntity> { // ... return await this.photoRepo.create(createPhotoDto) } // In photo.controller.ts @Post()

NestJs: How to have Body input shape different from entity's DTO?

徘徊边缘 提交于 2020-08-09 23:48:20
问题 I've a DTO for my Photo and Tag object that looks like this: export class PhotoDto { readonly title: string readonly file: string readonly tags: TagDto[] } export class TagDto { readonly name: string } I use the PhotoDto in my photo.service.ts and eventually in the photo.controller.ts for the creation of Photo: // In photo.service.ts async create(createPhotoDto: PhotoDto): Promise<PhotoEntity> { // ... return await this.photoRepo.create(createPhotoDto) } // In photo.controller.ts @Post()

NestJs: How to have Body input shape different from entity's DTO?

匆匆过客 提交于 2020-08-09 23:44:39
问题 I've a DTO for my Photo and Tag object that looks like this: export class PhotoDto { readonly title: string readonly file: string readonly tags: TagDto[] } export class TagDto { readonly name: string } I use the PhotoDto in my photo.service.ts and eventually in the photo.controller.ts for the creation of Photo: // In photo.service.ts async create(createPhotoDto: PhotoDto): Promise<PhotoEntity> { // ... return await this.photoRepo.create(createPhotoDto) } // In photo.controller.ts @Post()