nestjs

How to configure rate-limit with fastify-adapter in nest js

我只是一个虾纸丫 提交于 2021-02-10 20:27:27
问题 I Just started implementing API's Nest js and I am using Fastify adapter. I need help to configure Rate limit using FastifyAdapter in Nest JS. async function bootstrap() { const app = await NestFactory.create<NestFastifyApplication>( AppModule, new FastifyAdapter(), ); const limiter = fastifyRateLimit(fastify(), { timeWindow: 15 * 60 * 1000, // 15 minutes max: 100 // limit each IP to 100 requests per windowMs }, (err) => { }); app.use(limiter); await app.listen(configService.getPort()); }

NestJs/TypeORM: How to save Many to Many

给你一囗甜甜゛ 提交于 2021-02-10 19:39:34
问题 I am trying to save a Many to Many relationship. Each entity by itself is working great. Here are the two entity files I am working with: // location.entity @ManyToMany(type => User, user => user.locations, { eager: true, cascade: true }) @JoinTable() users: User[]; // user.entity @ManyToMany(type => Location, location => location.users, { eager: false }) locations: Location[]; Here is the user repository: // user.repository ... user.locations = locations; // [1,2,3] user.uuid = uuidv4(); try

How to use Prisma 2 CLI on Heroku

佐手、 提交于 2021-02-10 14:44:55
问题 I have deployed NestJs application on Heroku which uses Prisma 2, but when I run the command npx prisma --version on heroku bash I get Prisma CLI version: prisma/1.34.10 (linux-x64) node-v14.15.0 but I have installed prisma 2.11.0, I want to use Prisma 2 cli to introspect my existing database, and run prisma generate. 回答1: I managed to introspect my existing database and run prisma generate by adding heroku-postbuild command on my package.json in scripts section as show below: { "scripts": {

How to use Prisma 2 CLI on Heroku

风格不统一 提交于 2021-02-10 14:42:57
问题 I have deployed NestJs application on Heroku which uses Prisma 2, but when I run the command npx prisma --version on heroku bash I get Prisma CLI version: prisma/1.34.10 (linux-x64) node-v14.15.0 but I have installed prisma 2.11.0, I want to use Prisma 2 cli to introspect my existing database, and run prisma generate. 回答1: I managed to introspect my existing database and run prisma generate by adding heroku-postbuild command on my package.json in scripts section as show below: { "scripts": {

How to import a registerAsync in a dynamic Nestjs module?

大城市里の小女人 提交于 2021-02-10 12:45:58
问题 The bounty expires in 5 days . Answers to this question are eligible for a +500 reputation bounty. Mick wants to draw more attention to this question: I added a repo with an easy example to try this out: github.com/MickL/nestjs-inject-existing-provider been looking into the dynamic modules using the Advanced NestJS: How to build completely dynamic NestJS modules. (https://dev.to/nestjs/advanced-nestjs-how-to-build-completely-dynamic-nestjs-modules-1370) From what I've seen, most people use

How to import a registerAsync in a dynamic Nestjs module?

老子叫甜甜 提交于 2021-02-10 12:45:24
问题 The bounty expires in 5 days . Answers to this question are eligible for a +500 reputation bounty. Mick wants to draw more attention to this question: I added a repo with an easy example to try this out: github.com/MickL/nestjs-inject-existing-provider been looking into the dynamic modules using the Advanced NestJS: How to build completely dynamic NestJS modules. (https://dev.to/nestjs/advanced-nestjs-how-to-build-completely-dynamic-nestjs-modules-1370) From what I've seen, most people use

Run NestJS script from command line

为君一笑 提交于 2021-02-10 06:43:17
问题 I want to be able to run a script that parses an XML file using NestJS framework for a proof-of-concept, but I'm not sure how to do it. I created a scripts directory inside /src and placed my script.ts with an initial console.log there. How can I run commands within that file? Should I change the script.ts file to plain javascript instead of typescript and then run node myscript.ts? What is the correct approach for this manner? 回答1: You can add a bin property to your package.json with the

Run NestJS script from command line

筅森魡賤 提交于 2021-02-10 06:42:05
问题 I want to be able to run a script that parses an XML file using NestJS framework for a proof-of-concept, but I'm not sure how to do it. I created a scripts directory inside /src and placed my script.ts with an initial console.log there. How can I run commands within that file? Should I change the script.ts file to plain javascript instead of typescript and then run node myscript.ts? What is the correct approach for this manner? 回答1: You can add a bin property to your package.json with the

Docker Compose cannot connect to database

烂漫一生 提交于 2021-02-08 18:28:59
问题 I'm using nestjs for my backend and using typeorm as ORM. I tried to define my database and my application in an docker-compose file. If I'm running my database as a container and my application from my local machine it works well. My program connects and creates the tables etc. But if I try to connect the database from within my container or to start the container with docker-compose up it fails. Always get an ECONNREFUSED Error. Where is my mistake ? docker-compose.yml version: '3.1'

Docker Compose cannot connect to database

China☆狼群 提交于 2021-02-08 18:28:43
问题 I'm using nestjs for my backend and using typeorm as ORM. I tried to define my database and my application in an docker-compose file. If I'm running my database as a container and my application from my local machine it works well. My program connects and creates the tables etc. But if I try to connect the database from within my container or to start the container with docker-compose up it fails. Always get an ECONNREFUSED Error. Where is my mistake ? docker-compose.yml version: '3.1'