I have created a guard And i am using it on of my endpoints The point is it is faling because getRequest is not returning the authenticated user it is returning undefined How can i return the authenticated user from the response ? Answer You should use your JwtAuthGuard at your controller level since nest doesn’t have an order to
Tag: nestjs
How to deal with NestJS @Get() decorator?
This block of code works properly. I’m able to access both functions with the URL http://localhost:3000/vehicle/availableVehicles & http://localhost:3000/vehicle/1 accordingly But when I just swap between the 2 functions like code block below then the function availableVehicles() doesn’t work & the URL http://localhost:3000/vehicle/availableVehicles hits the getbyId() function. What to do? Or what I’m doing wrong? Thanks in advance. Answer You just
How to rate limit a NestJS API by multiple time intervals?
I am trying to rate limit my API with @NestJs/throttler. I want to set two different limit caps: 100 requests per 1 second 10,000 requests per 24 hours. Setting either one of these rate limits is explained in the docs and is pretty straight forwad. But, setting both limitations is not articulated in the docs. How can I rate limit
Unsafe use of expression of type ‘any’ for return statements in Typescript function
I keep getting a lint issue for this line .then((response): object => response.data) which states Unsafe use of expression of type ‘any’ Answer I suspect that it’s because response is a “generic object” and typescript can’t “identify” that it has a .data attribute. In order to fix that we can declare an interface of a type: and then use it
NestJs: Make sure your class is decorated with an appropriate decorator
I am using graphql-request as a GraphQL client to query a headless CMS to fetch stuff, modify and return to the original request/query. headless cms is hosted separately fyi. I have the following code : BlogPost is a model having the types : and FlatDateType has the following code it throws the following exception : Error: Cannot determine a GraphQL
Is there a way to use static method with dependency injection in NestJS?
An example is better than a long explanation: How can I replace BakeryService.myStaticMethodToGetPrice() to use dependency injection, so I can test things easily for example? Answer Static methods cannot use dependency injection. This is because the idea of dependency injection (at least to Nest) is to inject instances of the dependencies so that they can be leveraged later. The code
How can I see the list of JWT tokens generated(I`m using nestjs jwt) [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question Hello there I have an application that generates a JWT token for the user on logging in. But the problem is I want to add
How to print Firestore timestamp as formatted date and time like December 28,2020 at 3:52:04 AM UTC+5:30?
while fetching date from firestore I am getting Timestamp “seconds: 1608490949, nanoseconds: 275000000”.I want to print it as properly formatted date and time. As it is “December 28,2020 at 3:52:04 AM UTC+5:30”. Below is my pic of code Answer You can call javascript date functions here because this converting into javascript date https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString Or for more control on formatting, you
Nest.js cant resolve dependencies, can’t find my mistake
I’m doing a Nest.js program but I can’t find my dependencies problem. I have searched quite a lot and I have found a lot of answers regarding this problem, but I can’t figure out why my code isn´t working. So I have a product module which has his DTO´s, Entity, Controller, Service and module, besides it has an interface for
Differentiate 2 routes of a controller (NestJS)
EDIT: When I move the @Get(‘/random’) above the 2 other routes, it’s working… Weird I’m doing a NestJS server that just get some routes of the Breaking Bad API and displays the JSON in the routes of the server, I want to create 3 routes : 1 that returns a JSON of all characters of the show (/characters/all) 1 that