I read following documentation described nest command. https://docs.nestjs.com/cli/scripts According to the document, following must be added to package.json What are the –watch and –debug options? Answer In general, –watch means the terminal will stay open and watch for any file changes and then reload the server. –debug means it will log more messages to the console (e.g. info or warnings),
Tag: nestjs
NestJS controller not mapped
So I have an API that will be deployed in a docker container. This API has the authentications controller, simple and not something special. When I start up the API in development mode on my local machine, the auth controller will be found and everything is working fine. Same for building and running it on my local machine. But when
NestJs transform GRPC exception to HTTP exception
I have a HTTP server that connects to a gateway over GRPC. the gateway also connects to other . GRPC microservices. the flow looks like this: Client -> HttpServer -> GRPC server (gateway) -> GRPC microservice server X The way i handle errors currently is like so (please let me know if there is better practice) i will only show
Nest can’t resolve dependencies of the UserModel (?)
When I try to use MongooseModel on Users I am getting the following error Nest can’t resolve dependencies of the UserModel (?). Please make sure that the argument DatabaseConnection at index [0] is available in the MongooseModule context. /src/database/database.module.ts /src/database/database.provider.ts /src/app.module.ts /src/auth/auth.module.ts /src/users/user.module.ts Answer Instead of configuring mongoose statically in your database.provider.ts, you should use the MongooseModule.forRootAsync import:
extend existing API with custom endpoints
I’m creating an API for multiple customers. The core endpoints like /users are used by every customer but some endpoints rely on individual customization. So it might be that User A wants a special endpoint /groups and no other customer will have that feature. Just as a sidenote, each customer would also use his own database schema because of those
Expose normal http endpoint in NestJS Microservices
I have this microservice written with NestJs: But now I need to implement an endpoint /metrics for Prometheus. So the question is how do I do this with NestJs microservice From this issue I get the impression that it is not possible. Is this true and if so, is there a workaround I can use? I tried to apply middleware
how to send error codes in nestjs app from controller?
How can i send error codes in nestjs apart from 200? i tried to inject response object in a method but there is no method to send error. the above code send body with 20X status i want to send different status code like 400 or 500. Answer
Test NestJS Service against Actual Database
I would like to be able to test my Nest service against an actual database. I understand that most unit tests should use a mock object, but it also, at times, makes sense to test against the database itself. I have searched through SO and the GH issues for Nest, and am starting to reach the transitive closure of all
Inject TypeORM repository into NestJS service for mock data testing
There’s a longish discussion about how to do this in this issue. I’ve experimented with a number of the proposed solutions but I’m not having much luck. Could anyone provide a concrete example of how to test a service with an injected repository and mock data? Answer Let’s assume we have a very simple service that finds a user entity
NestJS Global Modules in tests
Is there a way to automatically provide all @Globalmodules into a TestModule ? (i.e without having to import them, the same way the main application works) So far, I had to make sure to insert any global modules into the import list of my call: Answer Global modules always have to be imported once for their providers to be available